Browse code

- minor bugs fixed

Jan Janak authored on 28/04/2003 22:08:52
Showing 3 changed files
... ...
@@ -85,5 +85,6 @@ void print_nameaddr(FILE* _o, name_addr_t* _a)
85 85
 	fprintf(_o, "---name-addr---\n");
86 86
 	fprintf(_o, "name: '%.*s'\n", _a->name.len, ZSW(_a->name.s));
87 87
 	fprintf(_o, "uri : '%.*s'\n", _a->uri.len, ZSW(_a->uri.s));
88
+	fprintf(_o, "len : %d\n", _a->len);
88 89
 	fprintf(_o, "---/name-addr---\n");
89 90
 }
... ...
@@ -310,6 +310,7 @@ int parse_params(str* _s, pclass_t _c, param_hooks_t* _h, param_t** _p)
310 310
 	}
311 311
 
312 312
 	memset(_h, 0, sizeof(param_hooks_t));
313
+	*_p = 0;
313 314
 
314 315
 	while(1) {
315 316
 		t = (param_t*)pkg_malloc(sizeof(param_t));
... ...
@@ -147,7 +147,8 @@ static inline void do_free_rr(rr_t** _r, int _shm)
147 147
 		ptr = *_r;
148 148
 		*_r = (*_r)->next;
149 149
 		if (ptr->params) {
150
-			free_params(ptr->params);
150
+			if (_shm) shm_free_params(ptr->params);
151
+			else free_params(ptr->params);
151 152
 		}
152 153
 		if (_shm) shm_free(ptr);
153 154
 		else pkg_free(ptr);
... ...
@@ -193,6 +194,7 @@ void print_rr(FILE* _o, rr_t* _r)
193 194
 		if (ptr->params) {
194 195
 			print_params(_o, ptr->params);
195 196
 		}
197
+		fprintf(_o, "len: %d\n", ptr->len);
196 198
 		fprintf(_o, "---/RR---\n");
197 199
 		ptr = ptr->next;
198 200
 	}
... ...
@@ -203,23 +205,23 @@ void print_rr(FILE* _o, rr_t* _r)
203 205
  * Translate all pointers in the structure and also
204 206
  * in all parameters in the list
205 207
  */
206
-static inline void xlate_pointers(struct sip_msg* _m, rr_t* _r)
208
+static inline void xlate_pointers(rr_t* _orig, rr_t* _r)
207 209
 {
208 210
 	param_t* ptr;
209
-	_r->nameaddr.uri.s = translate_pointer(_r->nameaddr.name.s, _m->buf, _r->nameaddr.uri.s);
211
+	_r->nameaddr.uri.s = translate_pointer(_r->nameaddr.name.s, _orig->nameaddr.name.s, _r->nameaddr.uri.s);
210 212
 	
211 213
 	ptr = _r->params;
212 214
 	while(ptr) {
213 215
 		     /*		if (ptr->type == P_R2) _r->r2 = ptr; */
214
-		ptr->name.s = translate_pointer(_r->nameaddr.name.s, _m->buf, ptr->name.s);
215
-		ptr->body.s = translate_pointer(_r->nameaddr.name.s, _m->buf, ptr->body.s);		
216
+		ptr->name.s = translate_pointer(_r->nameaddr.name.s, _orig->nameaddr.name.s, ptr->name.s);
217
+		ptr->body.s = translate_pointer(_r->nameaddr.name.s, _orig->nameaddr.name.s, ptr->body.s);		
216 218
 		ptr = ptr->next;
217 219
 	}
218 220
 }
219 221
 
220 222
 
221 223
 /*
222
- * Duplicate a single rr_t structure using pkg_malloc
224
+ * Duplicate a single rr_t structure using pkg_malloc or shm_malloc
223 225
  */
224 226
 static inline int do_duplicate_rr(struct sip_msg* _m, rr_t** _new, rr_t* _r, int _shm)
225 227
 {
... ...
@@ -243,7 +245,7 @@ static inline int do_duplicate_rr(struct sip_msg* _m, rr_t** _new, rr_t* _r, int
243 245
 		LOG(L_ERR, "duplicate_rr(): No memory left\n");
244 246
 		return -2;
245 247
 	}
246
-	memset(res, 0, sizeof(rr_t));
248
+	memcpy(res, _r, sizeof(rr_t));
247 249
 
248 250
         res->nameaddr.name.s = (char*)res + sizeof(rr_t);
249 251
 	memcpy(res->nameaddr.name.s, _r->nameaddr.name.s, len);
... ...
@@ -261,7 +263,7 @@ static inline int do_duplicate_rr(struct sip_msg* _m, rr_t** _new, rr_t* _r, int
261 263
 		return -3;
262 264
 	}
263 265
 
264
-	xlate_pointers(_m, res);
266
+	xlate_pointers(_r, res);
265 267
 	*_new = res;
266 268
 	return 0;
267 269
 }