Module: sip-router
Branch: 3.1
Commit: b64268bf768e979b4d7b34b5240b006dcba573ec
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b64268b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Feb 28 16:18:24 2011 +0100
core: order the list of headers that allocate pkg
- easier to spot the missing ones
(cherry picked from commit 2316acaa9adc27355e777d281bee8bfaf393cd6d)
---
parser/hf.c | 164 ++++++++++++++++++++++++----------------------------------
parser/hf.h | 38 +++++++-------
2 files changed, 87 insertions(+), 115 deletions(-)
diff --git a/parser/hf.c b/parser/hf.c
index 207a7ab..d094785 100644
--- a/parser/hf.c
+++ b/parser/hf.c
@@ -68,154 +68,134 @@ void clean_hdr_field(struct hdr_field* hf)
void** h_parsed;
if (hf->parsed){
- h_parsed=&hf->parsed; /*strict aliasing warnings workarround */
+ h_parsed=&hf->parsed; /* strict aliasing warnings workarround */
switch(hf->type){
- case HDR_VIA_T:
- free_via_list(hf->parsed);
- break;
-
- case HDR_TO_T:
- free_to(hf->parsed);
- break;
-
- case HDR_FROM_T:
- free_to(hf->parsed);
- break;
-
- case HDR_CSEQ_T:
- free_cseq(hf->parsed);
+ /* headers with pkg alloc for parsed structure (alphabetic order) */
+ case HDR_ACCEPT_T:
+ pkg_free(hf->parsed);
break;
- case HDR_CALLID_T:
+ case HDR_ALLOW_T:
+ free_allow_header(hf);
break;
- case HDR_SIPIFMATCH_T:
- free_sipifmatch((str **)h_parsed);
+ case HDR_AUTHORIZATION_T:
+ free_credentials((auth_body_t**)h_parsed);
break;
case HDR_CONTACT_T:
free_contact((contact_body_t**)h_parsed);
break;
- case HDR_MAXFORWARDS_T:
- break;
-
- case HDR_ROUTE_T:
- free_rr((rr_t**)h_parsed);
- break;
-
- case HDR_RECORDROUTE_T:
- free_rr((rr_t**)h_parsed);
+ case HDR_CONTENTDISPOSITION_T:
+ free_disposition( ((struct disposition**)h_parsed));
break;
- case HDR_CONTENTTYPE_T:
+ case HDR_CSEQ_T:
+ free_cseq(hf->parsed);
break;
- case HDR_CONTENTLENGTH_T:
+ case HDR_DATE_T:
+ free_date(hf->parsed);
break;
- case HDR_RETRY_AFTER_T:
+ case HDR_DIVERSION_T:
+ free_to(hf->parsed);
break;
- case HDR_AUTHORIZATION_T:
- free_credentials((auth_body_t**)h_parsed);
+ case HDR_EVENT_T:
+ free_event((event_t**)h_parsed);
break;
case HDR_EXPIRES_T:
free_expires((exp_body_t**)h_parsed);
break;
- case HDR_PROXYAUTH_T:
- free_credentials((auth_body_t**)h_parsed);
- break;
-
- case HDR_SUPPORTED_T:
- if(*h_parsed) {
- ((hf_parsed_t*)(*h_parsed))->hfree(*h_parsed);
- }
- break;
-
- case HDR_REQUIRE_T:
- break;
-
- case HDR_PROXYREQUIRE_T:
- break;
-
- case HDR_UNSUPPORTED_T:
- break;
-
- case HDR_ALLOW_T:
- free_allow_header(hf);
- break;
-
- case HDR_EVENT_T:
- free_event((event_t**)h_parsed);
- break;
-
- case HDR_ACCEPT_T:
- pkg_free(hf->parsed);
+ case HDR_FROM_T:
+ free_to(hf->parsed);
break;
- case HDR_ACCEPTLANGUAGE_T:
+ case HDR_IDENTITY_INFO_T:
+ free_identityinfo(hf->parsed);
break;
- case HDR_ORGANIZATION_T:
+ case HDR_IDENTITY_T:
+ free_identity(hf->parsed);
break;
- case HDR_PRIORITY_T:
+ case HDR_PAI_T:
+ free_to(hf->parsed);
break;
- case HDR_SUBJECT_T:
+ case HDR_PPI_T:
+ free_to(hf->parsed);
break;
- case HDR_USERAGENT_T:
+ case HDR_PROXYAUTH_T:
+ free_credentials((auth_body_t**)h_parsed);
break;
- case HDR_SERVER_T:
+ case HDR_RECORDROUTE_T:
+ free_rr((rr_t**)h_parsed);
break;
- case HDR_ACCEPTDISPOSITION_T:
+ case HDR_REFER_TO_T:
+ free_to(hf->parsed);
break;
- case HDR_CONTENTDISPOSITION_T:
- free_disposition( ((struct disposition**)h_parsed));
+ case HDR_ROUTE_T:
+ free_rr((rr_t**)h_parsed);
break;
- case HDR_DIVERSION_T:
+ case HDR_RPID_T:
free_to(hf->parsed);
break;
- case HDR_RPID_T:
- free_to(hf->parsed);
+ case HDR_SESSIONEXPIRES_T:
+ if(*h_parsed) {
+ ((hf_parsed_t*)(*h_parsed))->hfree(*h_parsed);
+ *h_parsed = 0;
+ }
break;
- case HDR_REFER_TO_T:
- free_to(hf->parsed);
+ case HDR_SIPIFMATCH_T:
+ free_sipifmatch((str **)h_parsed);
break;
case HDR_SUBSCRIPTION_STATE_T:
free_subscription_state((subscription_state_t**)h_parsed);
break;
- case HDR_DATE_T:
- free_date(hf->parsed);
- break;
-
- case HDR_IDENTITY_INFO_T:
- free_identityinfo(hf->parsed);
+ case HDR_SUPPORTED_T:
+ if(*h_parsed) {
+ ((hf_parsed_t*)(*h_parsed))->hfree(*h_parsed);
+ }
break;
- case HDR_IDENTITY_T:
- free_identity(hf->parsed);
+ case HDR_TO_T:
+ free_to(hf->parsed);
break;
- case HDR_SESSIONEXPIRES_T:
- if(*h_parsed) {
- ((hf_parsed_t*)(*h_parsed))->hfree(*h_parsed);
- *h_parsed = 0;
- }
+ case HDR_VIA_T:
+ free_via_list(hf->parsed);
break;
+ /* headers with no alloc for parsed structure */
+ case HDR_CALLID_T:
+ case HDR_MAXFORWARDS_T:
+ case HDR_CONTENTTYPE_T:
+ case HDR_CONTENTLENGTH_T:
+ case HDR_RETRY_AFTER_T:
+ case HDR_REQUIRE_T:
+ case HDR_PROXYREQUIRE_T:
+ case HDR_UNSUPPORTED_T:
+ case HDR_ACCEPTLANGUAGE_T:
+ case HDR_ORGANIZATION_T:
+ case HDR_PRIORITY_T:
+ case HDR_SUBJECT_T:
+ case HDR_USERAGENT_T:
+ case HDR_SERVER_T:
+ case HDR_ACCEPTDISPOSITION_T:
case HDR_MIN_SE_T:
case HDR_ACCEPTCONTACT_T:
case HDR_ALLOWEVENTS_T:
@@ -230,14 +210,6 @@ void clean_hdr_field(struct hdr_field* hf)
case HDR_REASON_T:
break;
- case HDR_PPI_T:
- free_to(hf->parsed);
- break;
-
- case HDR_PAI_T:
- free_to(hf->parsed);
- break;
-
default:
LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n",
hf->type);
diff --git a/parser/hf.h b/parser/hf.h
index 759dc6d..e880987 100644
--- a/parser/hf.h
+++ b/parser/hf.h
@@ -225,32 +225,32 @@ typedef struct hdr_parsed {
static inline int hdr_allocs_parse(struct hdr_field* hdr)
{
switch(hdr->type){
- case HDR_VIA_T:
- case HDR_TO_T:
- case HDR_FROM_T:
- case HDR_CSEQ_T:
- case HDR_CONTACT_T:
- case HDR_ROUTE_T:
- case HDR_RECORDROUTE_T:
- case HDR_AUTHORIZATION_T:
- case HDR_EXPIRES_T:
- case HDR_PROXYAUTH_T:
- case HDR_ALLOW_T:
- case HDR_EVENT_T:
case HDR_ACCEPT_T:
+ case HDR_ALLOW_T:
+ case HDR_AUTHORIZATION_T:
+ case HDR_CONTACT_T:
case HDR_CONTENTDISPOSITION_T:
- case HDR_DIVERSION_T:
+ case HDR_CSEQ_T:
case HDR_DATE_T:
- case HDR_RPID_T:
+ case HDR_DIVERSION_T:
+ case HDR_EVENT_T:
+ case HDR_EXPIRES_T:
+ case HDR_FROM_T:
+ case HDR_IDENTITY_INFO_T:
+ case HDR_IDENTITY_T:
+ case HDR_PAI_T:
+ case HDR_PPI_T:
+ case HDR_PROXYAUTH_T:
+ case HDR_RECORDROUTE_T:
case HDR_REFER_TO_T:
+ case HDR_ROUTE_T:
+ case HDR_RPID_T:
+ case HDR_SESSIONEXPIRES_T:
case HDR_SIPIFMATCH_T:
case HDR_SUBSCRIPTION_STATE_T:
- case HDR_IDENTITY_INFO_T:
- case HDR_IDENTITY_T:
case HDR_SUPPORTED_T:
- case HDR_SESSIONEXPIRES_T:
- case HDR_PPI_T:
- case HDR_PAI_T:
+ case HDR_TO_T:
+ case HDR_VIA_T:
return 1;
default:
return 0;