Browse Source

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 14 years ago
parent
commit
81d05af470
2 changed files with 10 additions and 0 deletions
  1. 3 0
      parser/hf.c
  2. 7 0
      parser/hf.h

+ 3 - 0
parser/hf.c

@@ -130,6 +130,9 @@ void clean_hdr_field(struct hdr_field* hf)
 			break;
 
 		case HDR_SUPPORTED_T:
+			if(*h_parsed) {
+				((hf_parsed_t*)(*h_parsed))->hfree(*h_parsed);
+			}
 			break;
 
 		case HDR_REQUIRE_T:

+ 7 - 0
parser/hf.h

@@ -213,6 +213,13 @@ typedef struct hdr_field {
 } hdr_field_t;
 
 
+/* type of the function to free the structure of parsed header field */
+typedef void (*hf_parsed_free_f)(void *parsed);
+
+/* structure to hold the function to free the parsed header field */
+typedef struct hdr_parsed {
+	hf_parsed_free_f hfree;
+} hf_parsed_t;
 
 /** returns true if the header links allocated memory on parse field. */
 static inline int hdr_allocs_parse(struct hdr_field* hdr)