Browse code

core: order the list of headers that allocate pkg

- easier to spot the missing ones

Daniel-Constantin Mierla authored on 28/02/2011 15:18:24
Showing 2 changed files
... ...
@@ -68,154 +68,134 @@ void clean_hdr_field(struct hdr_field* hf)
68 68
 	void** h_parsed;
69 69
 
70 70
 	if (hf->parsed){
71
-		h_parsed=&hf->parsed; /*strict aliasing warnings workarround */
71
+		h_parsed=&hf->parsed; /* strict aliasing warnings workarround */
72 72
 		switch(hf->type){
73
-		case HDR_VIA_T:
74
-			free_via_list(hf->parsed);
75
-			break;
76
-
77
-		case HDR_TO_T:
78
-			free_to(hf->parsed);
79
-			break;
80
-
81
-		case HDR_FROM_T:
82
-			free_to(hf->parsed);
83
-			break;
84
-
85
-		case HDR_CSEQ_T:
86
-			free_cseq(hf->parsed);
73
+		/* headers with pkg alloc for parsed structure (alphabetic order) */
74
+		case HDR_ACCEPT_T:
75
+			pkg_free(hf->parsed);
87 76
 			break;
88 77
 
89
-		case HDR_CALLID_T:
78
+		case HDR_ALLOW_T:
79
+			free_allow_header(hf);
90 80
 			break;
91 81
 
92
-		case HDR_SIPIFMATCH_T:
93
-			free_sipifmatch((str **)h_parsed);
82
+		case HDR_AUTHORIZATION_T:
83
+			free_credentials((auth_body_t**)h_parsed);
94 84
 			break;
95 85
 
96 86
 		case HDR_CONTACT_T:
97 87
 			free_contact((contact_body_t**)h_parsed);
98 88
 			break;
99 89
 
100
-		case HDR_MAXFORWARDS_T:
101
-			break;
102
-
103
-		case HDR_ROUTE_T:
104
-			free_rr((rr_t**)h_parsed);
105
-			break;
106
-
107
-		case HDR_RECORDROUTE_T:
108
-			free_rr((rr_t**)h_parsed);
90
+		case HDR_CONTENTDISPOSITION_T:
91
+			free_disposition( ((struct disposition**)h_parsed));
109 92
 			break;
110 93
 
111
-		case HDR_CONTENTTYPE_T:
94
+		case HDR_CSEQ_T:
95
+			free_cseq(hf->parsed);
112 96
 			break;
113 97
 
114
-		case HDR_CONTENTLENGTH_T:
98
+		case HDR_DATE_T:
99
+			free_date(hf->parsed);
115 100
 			break;
116 101
 
117
-		case HDR_RETRY_AFTER_T:
102
+		case HDR_DIVERSION_T:
103
+			free_to(hf->parsed);
118 104
 			break;
119 105
 
120
-		case HDR_AUTHORIZATION_T:
121
-			free_credentials((auth_body_t**)h_parsed);
106
+		case HDR_EVENT_T:
107
+			free_event((event_t**)h_parsed);
122 108
 			break;
123 109
 
124 110
 		case HDR_EXPIRES_T:
125 111
 			free_expires((exp_body_t**)h_parsed);
126 112
 			break;
127 113
 
128
-		case HDR_PROXYAUTH_T:
129
-			free_credentials((auth_body_t**)h_parsed);
130
-			break;
131
-
132
-		case HDR_SUPPORTED_T:
133
-			if(*h_parsed) {
134
-				((hf_parsed_t*)(*h_parsed))->hfree(*h_parsed);
135
-			}
136
-			break;
137
-
138
-		case HDR_REQUIRE_T:
139
-			break;
140
-
141
-		case HDR_PROXYREQUIRE_T:
142
-			break;
143
-
144
-		case HDR_UNSUPPORTED_T:
145
-			break;
146
-
147
-		case HDR_ALLOW_T:
148
-			free_allow_header(hf);
149
-			break;
150
-
151
-		case HDR_EVENT_T:
152
-			free_event((event_t**)h_parsed);
153
-			break;
154
-
155
-		case HDR_ACCEPT_T:
156
-			pkg_free(hf->parsed);
114
+		case HDR_FROM_T:
115
+			free_to(hf->parsed);
157 116
 			break;
158 117
 
159
-		case HDR_ACCEPTLANGUAGE_T:
118
+		case HDR_IDENTITY_INFO_T:
119
+			free_identityinfo(hf->parsed);
160 120
 			break;
161 121
 
162
-		case HDR_ORGANIZATION_T:
122
+		case HDR_IDENTITY_T:
123
+			free_identity(hf->parsed);
163 124
 			break;
164 125
 
165
-		case HDR_PRIORITY_T:
126
+		case HDR_PAI_T:
127
+			free_to(hf->parsed);
166 128
 			break;
167 129
 
168
-		case HDR_SUBJECT_T:
130
+		case HDR_PPI_T:
131
+			free_to(hf->parsed);
169 132
 			break;
170 133
 
171
-		case HDR_USERAGENT_T:
134
+		case HDR_PROXYAUTH_T:
135
+			free_credentials((auth_body_t**)h_parsed);
172 136
 			break;
173 137
 
174
-		case HDR_SERVER_T:
138
+		case HDR_RECORDROUTE_T:
139
+			free_rr((rr_t**)h_parsed);
175 140
 			break;
176 141
 
177
-		case HDR_ACCEPTDISPOSITION_T:
142
+		case HDR_REFER_TO_T:
143
+			free_to(hf->parsed);
178 144
 			break;
179 145
 
180
-		case HDR_CONTENTDISPOSITION_T:
181
-			free_disposition( ((struct disposition**)h_parsed));
146
+		case HDR_ROUTE_T:
147
+			free_rr((rr_t**)h_parsed);
182 148
 			break;
183 149
 
184
-		case HDR_DIVERSION_T:
150
+		case HDR_RPID_T:
185 151
 			free_to(hf->parsed);
186 152
 			break;
187 153
 
188
-		case HDR_RPID_T:
189
-			free_to(hf->parsed);
154
+		case HDR_SESSIONEXPIRES_T:
155
+			if(*h_parsed) {
156
+				((hf_parsed_t*)(*h_parsed))->hfree(*h_parsed);
157
+				*h_parsed = 0;
158
+			}
190 159
 			break;
191 160
 
192
-		case HDR_REFER_TO_T:
193
-			free_to(hf->parsed);
161
+		case HDR_SIPIFMATCH_T:
162
+			free_sipifmatch((str **)h_parsed);
194 163
 			break;
195 164
 
196 165
 		case HDR_SUBSCRIPTION_STATE_T:
197 166
 			free_subscription_state((subscription_state_t**)h_parsed);
198 167
 			break;
199 168
 
200
-		case HDR_DATE_T:
201
-			free_date(hf->parsed);
202
-			break;
203
-
204
-		case HDR_IDENTITY_INFO_T:
205
-			free_identityinfo(hf->parsed);
169
+		case HDR_SUPPORTED_T:
170
+			if(*h_parsed) {
171
+				((hf_parsed_t*)(*h_parsed))->hfree(*h_parsed);
172
+			}
206 173
 			break;
207 174
 
208
-		case HDR_IDENTITY_T:
209
-			free_identity(hf->parsed);
175
+		case HDR_TO_T:
176
+			free_to(hf->parsed);
210 177
 			break;
211 178
 
212
-		case HDR_SESSIONEXPIRES_T:
213
-			if(*h_parsed) {
214
-				((hf_parsed_t*)(*h_parsed))->hfree(*h_parsed);
215
-				*h_parsed = 0;
216
-			}
179
+		case HDR_VIA_T:
180
+			free_via_list(hf->parsed);
217 181
 			break;
218 182
 
183
+		/* headers with no alloc for parsed structure */
184
+		case HDR_CALLID_T:
185
+		case HDR_MAXFORWARDS_T:
186
+		case HDR_CONTENTTYPE_T:
187
+		case HDR_CONTENTLENGTH_T:
188
+		case HDR_RETRY_AFTER_T:
189
+		case HDR_REQUIRE_T:
190
+		case HDR_PROXYREQUIRE_T:
191
+		case HDR_UNSUPPORTED_T:
192
+		case HDR_ACCEPTLANGUAGE_T:
193
+		case HDR_ORGANIZATION_T:
194
+		case HDR_PRIORITY_T:
195
+		case HDR_SUBJECT_T:
196
+		case HDR_USERAGENT_T:
197
+		case HDR_SERVER_T:
198
+		case HDR_ACCEPTDISPOSITION_T:
219 199
 		case HDR_MIN_SE_T:
220 200
 		case HDR_ACCEPTCONTACT_T:
221 201
 		case HDR_ALLOWEVENTS_T:
... ...
@@ -230,14 +210,6 @@ void clean_hdr_field(struct hdr_field* hf)
230 210
 		case HDR_REASON_T:
231 211
 			break;
232 212
 
233
-		case HDR_PPI_T:
234
-			free_to(hf->parsed);
235
-			break;
236
-
237
-		case HDR_PAI_T:
238
-			free_to(hf->parsed);
239
-			break;
240
-
241 213
 		default:
242 214
 			LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n",
243 215
 			    hf->type);
... ...
@@ -225,32 +225,32 @@ typedef struct hdr_parsed {
225 225
 static inline int hdr_allocs_parse(struct hdr_field* hdr)
226 226
 {
227 227
 	switch(hdr->type){
228
-		case HDR_VIA_T:
229
-		case HDR_TO_T:
230
-		case HDR_FROM_T:
231
-		case HDR_CSEQ_T:
232
-		case HDR_CONTACT_T:
233
-		case HDR_ROUTE_T:
234
-		case HDR_RECORDROUTE_T:
235
-		case HDR_AUTHORIZATION_T:
236
-		case HDR_EXPIRES_T:
237
-		case HDR_PROXYAUTH_T:
238
-		case HDR_ALLOW_T:
239
-		case HDR_EVENT_T:
240 228
 		case HDR_ACCEPT_T:
229
+		case HDR_ALLOW_T:
230
+		case HDR_AUTHORIZATION_T:
231
+		case HDR_CONTACT_T:
241 232
 		case HDR_CONTENTDISPOSITION_T:
242
-		case HDR_DIVERSION_T:
233
+		case HDR_CSEQ_T:
243 234
 		case HDR_DATE_T:
244
-		case HDR_RPID_T:
235
+		case HDR_DIVERSION_T:
236
+		case HDR_EVENT_T:
237
+		case HDR_EXPIRES_T:
238
+		case HDR_FROM_T:
239
+		case HDR_IDENTITY_INFO_T:
240
+		case HDR_IDENTITY_T:
241
+		case HDR_PAI_T:
242
+		case HDR_PPI_T:
243
+		case HDR_PROXYAUTH_T:
244
+		case HDR_RECORDROUTE_T:
245 245
 		case HDR_REFER_TO_T:
246
+		case HDR_ROUTE_T:
247
+		case HDR_RPID_T:
248
+		case HDR_SESSIONEXPIRES_T:
246 249
 		case HDR_SIPIFMATCH_T:
247 250
 		case HDR_SUBSCRIPTION_STATE_T:
248
-		case HDR_IDENTITY_INFO_T:
249
-		case HDR_IDENTITY_T:
250 251
 		case HDR_SUPPORTED_T:
251
-		case HDR_SESSIONEXPIRES_T:
252
-		case HDR_PPI_T:
253
-		case HDR_PAI_T:
252
+		case HDR_TO_T:
253
+		case HDR_VIA_T:
254 254
 			return 1;
255 255
 		default:
256 256
 			return 0;