Module: sip-router Branch: 3.1 Commit: 0299c9e29cd51b9c0fba8cdad0e1354e95f4c17c URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0299c9e2...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Sun Feb 27 16:40:37 2011 +0100
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 (cherry picked from commit 81d05af470d979b3d3f104bbdaa287b3fa58b57c)
---
parser/hf.c | 3 +++ parser/hf.h | 7 +++++++ 2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/parser/hf.c b/parser/hf.c index fe6b7a7..8863a10 100644 --- a/parser/hf.c +++ b/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: diff --git a/parser/hf.h b/parser/hf.h index f496e9a..035c91c 100644 --- a/parser/hf.h +++ b/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)