Browse code

core: framework for generic free of parsed headers

- the structure of parsed headers can define as first field a function
to free the content
- this allow to implement the parser for headers our of the core

Daniel-Constantin Mierla authored on 27/02/2011 15:40:37
Showing 2 changed files
... ...
@@ -130,6 +130,9 @@ void clean_hdr_field(struct hdr_field* hf)
130 130
 			break;
131 131
 
132 132
 		case HDR_SUPPORTED_T:
133
+			if(*h_parsed) {
134
+				((hf_parsed_t*)(*h_parsed))->hfree(*h_parsed);
135
+			}
133 136
 			break;
134 137
 
135 138
 		case HDR_REQUIRE_T:
... ...
@@ -213,6 +213,13 @@ typedef struct hdr_field {
213 213
 } hdr_field_t;
214 214
 
215 215
 
216
+/* type of the function to free the structure of parsed header field */
217
+typedef void (*hf_parsed_free_f)(void *parsed);
218
+
219
+/* structure to hold the function to free the parsed header field */
220
+typedef struct hdr_parsed {
221
+	hf_parsed_free_f hfree;
222
+} hf_parsed_t;
216 223
 
217 224
 /** returns true if the header links allocated memory on parse field. */
218 225
 static inline int hdr_allocs_parse(struct hdr_field* hdr)