Browse code

lost: memory leak fix and code refactoring

Wolfgang Kampichler authored on 31/03/2021 21:14:14
Showing 4 changed files
... ...
@@ -150,7 +150,7 @@ char *lost_held_type(char *type, int *exact, int *lgth)
150 150
 	return ret;
151 151
 
152 152
 err:
153
-	LM_ERR("no more private memory\n");
153
+	PKG_MEM_ERROR;
154 154
 	/* clean up */
155 155
 	if(ret != NULL) {
156 156
 		pkg_free(ret);
... ...
@@ -174,7 +174,7 @@ int lost_held_function(struct sip_msg *_m, char *_con, char *_pidf, char *_url,
174 174
 	pv_value_t pvurl;
175 175
 	pv_value_t pverr;
176 176
 
177
-	p_held_t held = NULL;
177
+	p_lost_held_t held = NULL;
178 178
 
179 179
 	xmlDocPtr doc = NULL;
180 180
 	xmlNodePtr root = NULL;
... ...
@@ -552,6 +552,7 @@ int lost_held_dereference(struct sip_msg *_m, char *_url, char *_pidf,
552 552
 	char *rtype = NULL;
553 553
 
554 554
 	long ltime = 0;
555
+	long rtime = 0;
555 556
 
556 557
 	int len = 0;
557 558
 	int curl = 0;
... ...
@@ -609,24 +610,22 @@ int lost_held_dereference(struct sip_msg *_m, char *_url, char *_pidf,
609 610
 		}
610 611
 	}
611 612
 
612
-	/* default responseTime: emergencyRouting */
613
-	heldreq = lost_held_post_request(&len, 0, rtype);
614
-
615
-	/* responseTime: milliseconds */
616 613
 	if((ltime > 0) && (strlen(ptr) == 0)) {
617
-		heldreq = lost_held_post_request(&len, ltime, rtype);
618
-	}
619
-
620
-	/* responseTime: emergencyRouting|emergencyDispatch */
621
-	if((ltime == 0) && (strlen(ptr) > 0)) {
614
+		/* responseTime: milliseconds */
615
+		rtime = ltime;
616
+	} else if((ltime == 0) && (strlen(ptr) > 0)) {
622 617
 		if(strncasecmp(ptr, HELD_ED, strlen(HELD_ED)) == 0) {
623
-			heldreq = lost_held_post_request(&len, -1, rtype);
624
-		}
625
-		if(strncasecmp(ptr, HELD_ER, strlen(HELD_ER)) == 0) {
626
-			heldreq = lost_held_post_request(&len, 0, rtype);
618
+			/* responseTime: emergencyDispatch */
619
+			rtime = -1;
620
+		} else if(strncasecmp(ptr, HELD_ER, strlen(HELD_ER)) == 0) {
621
+			/* responseTime: emergencyRouting */
622
+			rtime = 0;
627 623
 		}
628 624
 	}
629 625
 
626
+	/* get the HELD request body */
627
+	heldreq = lost_held_post_request(&len, rtime, rtype);
628
+
630 629
 	/* clean up */
631 630
 	if(rtype != NULL) {
632 631
 		pkg_free(rtype);
... ...
@@ -760,8 +759,8 @@ int lost_function(struct sip_msg *_m, char *_con, char *_uri, char *_name,
760 759
 	pv_value_t pvuri;
761 760
 	pv_value_t pverr;
762 761
 
763
-	p_loc_t loc = NULL;
764
-	p_geolist_t geolist = NULL;
762
+	p_lost_loc_t loc = NULL;
763
+	p_lost_geolist_t geolist = NULL;
765 764
 	p_fsr_t fsrdata = NULL;
766 765
 
767 766
 	str name = STR_NULL; /* return value displayName */
... ...
@@ -1068,7 +1067,10 @@ int lost_function(struct sip_msg *_m, char *_con, char *_uri, char *_name,
1068 1067
 					/* get the first uri element */
1069 1068
 					if((tmp.s = fsrdata->uri->value) != NULL) {
1070 1069
 						tmp.len = strlen(fsrdata->uri->value);
1071
-						uri.s = lost_copy_string(tmp, &uri.len);
1070
+						if(pkg_str_dup(&uri, &tmp) < 0) {
1071
+							LM_ERR("could not copy: [%.*s]\n", tmp.len, tmp.s);
1072
+							goto err;
1073
+						}
1072 1074
 					}
1073 1075
 				} else {
1074 1076
 					LM_ERR("uri not found: [%.*s]\n", ret.len, ret.s);
... ...
@@ -1078,7 +1080,10 @@ int lost_function(struct sip_msg *_m, char *_con, char *_uri, char *_name,
1078 1080
 					/* get the displayName element */
1079 1081
 					if((tmp.s = fsrdata->mapping->name->text) != NULL) {
1080 1082
 						tmp.len = strlen(fsrdata->mapping->name->text);
1081
-						name.s = lost_copy_string(tmp, &name.len);
1083
+						if(pkg_str_dup(&name, &tmp) < 0) {
1084
+							LM_ERR("could not copy: [%.*s]\n", tmp.len, tmp.s);
1085
+							goto err;
1086
+						}
1082 1087
 					}
1083 1088
 				} else {
1084 1089
 					LM_ERR("name not found: [%.*s]\n", ret.len, ret.s);
... ...
@@ -1092,7 +1097,10 @@ int lost_function(struct sip_msg *_m, char *_con, char *_uri, char *_name,
1092 1097
 				if(fsrdata->errors != NULL) {
1093 1098
 					if((tmp.s = fsrdata->errors->issue->type) != NULL) {
1094 1099
 						tmp.len = strlen(fsrdata->errors->issue->type);
1095
-						err.s = lost_copy_string(tmp, &err.len);
1100
+						if(pkg_str_dup(&err, &tmp) < 0) {
1101
+							LM_ERR("could not copy: [%.*s]\n", tmp.len, tmp.s);
1102
+							goto err;
1103
+						}
1096 1104
 					}
1097 1105
 					/* clean up */
1098 1106
 					tmp.s = NULL;
... ...
@@ -1132,7 +1140,10 @@ int lost_function(struct sip_msg *_m, char *_con, char *_uri, char *_name,
1132 1140
 							}
1133 1141
 						}
1134 1142
 						/* remember the redirect target */
1135
-						oldurl.s = lost_copy_string(url, &oldurl.len);
1143
+						if(pkg_str_dup(&oldurl, &url) < 0) {
1144
+							LM_ERR("could not copy: [%.*s]\n", url.len, url.s);
1145
+							goto err;
1146
+						}
1136 1147
 						/* clean up */
1137 1148
 						lost_free_findServiceResponse(&fsrdata);
1138 1149
 						lost_free_string(&ret);
... ...
@@ -245,7 +245,7 @@ p_type_t lost_new_response_type(void)
245 245
 
246 246
 	res = (p_type_t)pkg_malloc(sizeof(s_type_t));
247 247
 	if(res == NULL) {
248
-		LM_ERR("no more private memory\n");
248
+		PKG_MEM_ERROR;
249 249
 		return NULL;
250 250
 	}
251 251
 	res->type = NULL;
... ...
@@ -254,7 +254,7 @@ p_type_t lost_new_response_type(void)
254 254
 
255 255
 	res->info = (p_info_t)pkg_malloc(sizeof(s_info_t));
256 256
 	if(res->info == NULL) {
257
-		LM_ERR("no more private memory\n");
257
+		PKG_MEM_ERROR;
258 258
 	} else {
259 259
 		res->info->text = NULL;
260 260
 		res->info->lang = NULL;
... ...
@@ -275,7 +275,7 @@ p_issue_t lost_new_response_issues(void)
275 275
 
276 276
 	res = (p_issue_t)pkg_malloc(sizeof(s_issue_t));
277 277
 	if(res == NULL) {
278
-		LM_ERR("no more private memory\n");
278
+		PKG_MEM_ERROR;
279 279
 		return NULL;
280 280
 	}
281 281
 	res->issue = NULL;
... ...
@@ -296,7 +296,7 @@ p_data_t lost_new_response_data(void)
296 296
 
297 297
 	res = (p_data_t)pkg_malloc(sizeof(s_data_t));
298 298
 	if(res == NULL) {
299
-		LM_ERR("no more private memory\n");
299
+		PKG_MEM_ERROR;
300 300
 		return NULL;
301 301
 	}
302 302
 	res->expires = NULL;
... ...
@@ -322,7 +322,7 @@ p_list_t lost_new_response_list(void)
322 322
 
323 323
 	list = (p_list_t)pkg_malloc(sizeof(s_list_t));
324 324
 	if(list == NULL) {
325
-		LM_ERR("no more private memory\n");
325
+		PKG_MEM_ERROR;
326 326
 		return NULL;
327 327
 	}
328 328
 
... ...
@@ -582,7 +582,7 @@ p_issue_t lost_get_response_issues(xmlNodePtr node)
582 582
 			/* parse the element */
583 583
 			issue = lost_new_response_type();
584 584
 			if(issue == NULL) {
585
-				LM_ERR("no more private memory\n");
585
+				PKG_MEM_ERROR;
586 586
 				pkg_free(list);
587 587
 				pkg_free(new);
588 588
 				return NULL;
... ...
@@ -752,7 +752,7 @@ p_info_t lost_get_response_info(
752 752
 
753 753
 	res = (p_info_t)pkg_malloc(sizeof(s_info_t));
754 754
 	if(res == NULL) {
755
-		LM_ERR("no more private memory\n");
755
+		PKG_MEM_ERROR;
756 756
 		return NULL;
757 757
 	} else {
758 758
 		res->text = NULL;
... ...
@@ -907,7 +907,7 @@ p_fsr_t lost_parse_findServiceResponse(str ret)
907 907
 
908 908
 	res = lost_new_response();
909 909
 	if(res == NULL) {
910
-		LM_ERR("no more private memory\n");
910
+		PKG_MEM_ERROR;
911 911
 		xmlFreeDoc(doc); /* clean up */
912 912
 		return NULL;
913 913
 	}
... ...
@@ -916,7 +916,7 @@ p_fsr_t lost_parse_findServiceResponse(str ret)
916 916
 	if(!xmlStrcmp(root->name, (unsigned char *)ROOT_NODE)) {
917 917
 		m = lost_new_response_data();
918 918
 		if(m == NULL) {
919
-			LM_ERR("no more private memory\n");
919
+			PKG_MEM_ERROR;
920 920
 			/* clean up */
921 921
 			xmlFreeDoc(doc);
922 922
 			lost_free_findServiceResponse(&res);
... ...
@@ -964,7 +964,7 @@ p_fsr_t lost_parse_findServiceResponse(str ret)
964 964
 	} else if(!xmlStrcmp(root->name, (unsigned char *)RED_NODE)) {
965 965
 		r = lost_new_response_type();
966 966
 		if(r == NULL) {
967
-			LM_ERR("no more private memory\n");
967
+			PKG_MEM_ERROR;
968 968
 			xmlFreeDoc(doc); /* clean up */
969 969
 			lost_free_findServiceResponse(&res);
970 970
 			return NULL;
... ...
@@ -104,14 +104,14 @@ void lost_rand_str(char *dest, size_t lgth)
104 104
  * lost_new_loc(urn)
105 105
  * creates a new location object in private memory and returns a pointer
106 106
  */
107
-p_loc_t lost_new_loc(str rurn)
107
+p_lost_loc_t lost_new_loc(str rurn)
108 108
 {
109
-	s_loc_t *ptr = NULL;
109
+	s_lost_loc_t *ptr = NULL;
110 110
 
111 111
 	char *id = NULL;
112 112
 	char *urn = NULL;
113 113
 
114
-	ptr = (s_loc_t *)pkg_malloc(sizeof(s_loc_t));
114
+	ptr = (s_lost_loc_t *)pkg_malloc(sizeof(s_lost_loc_t));
115 115
 	if(ptr == NULL) {
116 116
 		goto err;
117 117
 	}
... ...
@@ -149,7 +149,7 @@ p_loc_t lost_new_loc(str rurn)
149 149
 	return ptr;
150 150
 
151 151
 err:
152
-	LM_ERR("no more private memory\n");
152
+	PKG_MEM_ERROR;
153 153
 	return NULL;
154 154
 }
155 155
 
... ...
@@ -157,14 +157,14 @@ err:
157 157
  * lost_new_held(uri, type, time, exact)
158 158
  * creates a new held object in private memory and returns a pointer
159 159
  */
160
-p_held_t lost_new_held(str s_uri, str s_type, int time, int exact)
160
+p_lost_held_t lost_new_held(str s_uri, str s_type, int time, int exact)
161 161
 {
162
-	s_held_t *ptr = NULL;
162
+	s_lost_held_t *ptr = NULL;
163 163
 
164 164
 	char *uri = NULL;
165 165
 	char *type = NULL;
166 166
 
167
-	ptr = (s_held_t *)pkg_malloc(sizeof(s_held_t));
167
+	ptr = (s_lost_held_t *)pkg_malloc(sizeof(s_lost_held_t));
168 168
 	if(ptr == NULL) {
169 169
 		goto err;
170 170
 	}
... ...
@@ -198,7 +198,7 @@ p_held_t lost_new_held(str s_uri, str s_type, int time, int exact)
198 198
 	return ptr;
199 199
 
200 200
 err:
201
-	LM_ERR("no more private memory\n");
201
+	PKG_MEM_ERROR;
202 202
 	return NULL;
203 203
 }
204 204
 
... ...
@@ -206,9 +206,9 @@ err:
206 206
  * lost_free_loc(ptr)
207 207
  * frees a location object
208 208
  */
209
-void lost_free_loc(p_loc_t *loc)
209
+void lost_free_loc(p_lost_loc_t *loc)
210 210
 {
211
-	p_loc_t ptr;
211
+	p_lost_loc_t ptr;
212 212
 
213 213
 	if(*loc == NULL)
214 214
 		return;
... ...
@@ -238,9 +238,9 @@ void lost_free_loc(p_loc_t *loc)
238 238
  * lost_free_loc(ptr)
239 239
  * frees a held location request object
240 240
  */
241
-void lost_free_held(p_held_t *held)
241
+void lost_free_held(p_lost_held_t *held)
242 242
 {
243
-	p_held_t ptr;
243
+	p_lost_held_t ptr;
244 244
 
245 245
 	if(held == NULL)
246 246
 		return;
... ...
@@ -258,7 +258,8 @@ void lost_free_held(p_held_t *held)
258 258
 
259 259
 /*
260 260
  * lost_copy_string(str, int*) {
261
- * copies a string and returns string allocated in private memory 
261
+ * copies a string and returns a zero terminated string allocated
262
+ * in private memory
262 263
  */
263 264
 char *lost_copy_string(str src, int *lgth)
264 265
 {
... ...
@@ -270,7 +271,7 @@ char *lost_copy_string(str src, int *lgth)
270 271
 	}
271 272
 	res = (char *)pkg_malloc((src.len + 1) * sizeof(char));
272 273
 	if(res == NULL) {
273
-		LM_ERR("no more private memory\n");
274
+		PKG_MEM_ERROR;
274 275
 		*lgth = 0;
275 276
 	} else {
276 277
 		memset(res, 0, src.len + 1);
... ...
@@ -328,7 +329,7 @@ char *lost_get_content(xmlNodePtr node, const char *name, int *lgth)
328 329
 		trimmed = lost_trim_content(content, &len);
329 330
 		cnt = (char *)pkg_malloc((len + 1) * sizeof(char));
330 331
 		if(cnt == NULL) {
331
-			LM_ERR("no more private memory\n");
332
+			PKG_MEM_ERROR;
332 333
 			xmlFree(content);
333 334
 			return cnt;
334 335
 		}
... ...
@@ -364,7 +365,7 @@ char *lost_get_property(xmlNodePtr node, const char *name, int *lgth)
364 365
 		len = strlen(content);
365 366
 		cnt = (char *)pkg_malloc((len + 1) * sizeof(char));
366 367
 		if(cnt == NULL) {
367
-			LM_ERR("no more private memory\n");
368
+			PKG_MEM_ERROR;
368 369
 			xmlFree(content);
369 370
 			return cnt;
370 371
 		}
... ...
@@ -409,7 +410,7 @@ char *lost_get_childname(xmlNodePtr node, const char *name, int *lgth)
409 410
 	trimmed = lost_trim_content((char *)child->name, &len);
410 411
 	cnt = (char *)pkg_malloc((len + 1) * sizeof(char));
411 412
 	if(cnt == NULL) {
412
-		LM_ERR("no more private memory\n");
413
+		PKG_MEM_ERROR;
413 414
 		return cnt;
414 415
 	}
415 416
 	memset(cnt, 0, len + 1);
... ...
@@ -425,11 +426,11 @@ char *lost_get_childname(xmlNodePtr node, const char *name, int *lgth)
425 426
  * lost_get_geolocation_header(msg, hdr)
426 427
  * gets the Geolocation header value and returns 1 on success
427 428
  */
428
-p_geolist_t lost_get_geolocation_header(struct sip_msg *msg, int *items)
429
+p_lost_geolist_t lost_get_geolocation_header(struct sip_msg *msg, int *items)
429 430
 {
430 431
 	struct hdr_field *hf;
431 432
 	str hdr = STR_NULL;
432
-	p_geolist_t list = NULL;
433
+	p_lost_geolist_t list = NULL;
433 434
 
434 435
 	if(parse_headers(msg, HDR_EOH_F, 0) == -1) {
435 436
 		LM_ERR("failed to parse SIP headers\n");
... ...
@@ -487,7 +488,7 @@ char *lost_get_pai_header(struct sip_msg *msg, int *lgth)
487 488
 				/* first, get some memory */
488 489
 				pai_body = pkg_malloc(sizeof(to_body_t));
489 490
 				if(pai_body == NULL) {
490
-					LM_ERR("no more private memory\n");
491
+					PKG_MEM_ERROR;
491 492
 					return res;
492 493
 				}
493 494
 				/* parse P-A-I body */
... ...
@@ -502,7 +503,7 @@ char *lost_get_pai_header(struct sip_msg *msg, int *lgth)
502 503
 					res = (char *)pkg_malloc(
503 504
 							(pai_body->uri.len + 1) * sizeof(char));
504 505
 					if(res == NULL) {
505
-						LM_ERR("no more private memory\n");
506
+						PKG_MEM_ERROR;
506 507
 						pkg_free(pai_body);
507 508
 						return res;
508 509
 					} else {
... ...
@@ -649,7 +650,7 @@ char *lost_get_from_header(struct sip_msg *msg, int *lgth)
649 650
 
650 651
 	res = (char *)pkg_malloc((f_body->uri.len + 1) * sizeof(char));
651 652
 	if(res == NULL) {
652
-		LM_ERR("no more private memory\n");
653
+		PKG_MEM_ERROR;
653 654
 		return res;
654 655
 	} else {
655 656
 		memset(res, 0, f_body->uri.len + 1);
... ...
@@ -666,9 +667,9 @@ char *lost_get_from_header(struct sip_msg *msg, int *lgth)
666 667
  * lost_free_geoheader_list(list)
667 668
  * removes geoheader list from private memory
668 669
  */
669
-void lost_free_geoheader_list(p_geolist_t *list)
670
+void lost_free_geoheader_list(p_lost_geolist_t *list)
670 671
 {
671
-	p_geolist_t curr;
672
+	p_lost_geolist_t curr;
672 673
 
673 674
 	while((curr = *list) != NULL) {
674 675
 		*list = curr->next;
... ...
@@ -690,9 +691,9 @@ void lost_free_geoheader_list(p_geolist_t *list)
690 691
  * lost_get_geoheader_value(list, type, rtype)
691 692
  * returns geoheader value and type (rtype) of given type
692 693
  */
693
-char *lost_get_geoheader_value(p_geolist_t list, geotype_t type, int *rtype)
694
+char *lost_get_geoheader_value(p_lost_geolist_t list, lost_geotype_t type, int *rtype)
694 695
 {
695
-	p_geolist_t head = list;
696
+	p_lost_geolist_t head = list;
696 697
 	char *value = NULL;
697 698
 
698 699
 	if(head == NULL) {
... ...
@@ -722,11 +723,11 @@ char *lost_get_geoheader_value(p_geolist_t list, geotype_t type, int *rtype)
722 723
  * lost_reverse_geoheader_list(list)
723 724
  * reverses list order
724 725
  */
725
-void lost_reverse_geoheader_list(p_geolist_t *head)
726
+void lost_reverse_geoheader_list(p_lost_geolist_t *head)
726 727
 {
727
-	p_geolist_t prev = NULL;
728
-	p_geolist_t next = NULL;
729
-	p_geolist_t current = *head;
728
+	p_lost_geolist_t prev = NULL;
729
+	p_lost_geolist_t next = NULL;
730
+	p_lost_geolist_t current = *head;
730 731
 
731 732
 	while(current != NULL) {
732 733
 		next = current->next;
... ...
@@ -748,7 +749,7 @@ char *lost_copy_geoheader_value(char *src, int len)
748 749
 
749 750
 	res = (char *)pkg_malloc((len + 1) * sizeof(char));
750 751
 	if(res == NULL) {
751
-		LM_ERR("no more private memory\n");
752
+		PKG_MEM_ERROR;
752 753
 		return res;
753 754
 	} else {
754 755
 		memset(res, 0, len + 1);
... ...
@@ -764,7 +765,7 @@ char *lost_copy_geoheader_value(char *src, int len)
764 765
  * searches and parses Geolocation header and returns a list
765 766
  * allocated in private memory and an item count
766 767
  */
767
-int lost_new_geoheader_list(p_geolist_t *list, str hdr)
768
+int lost_new_geoheader_list(p_lost_geolist_t *list, str hdr)
768 769
 {
769 770
 	char *search = NULL;
770 771
 	char *cidptr = NULL;
... ...
@@ -775,7 +776,7 @@ int lost_new_geoheader_list(p_geolist_t *list, str hdr)
775 776
 	int len = 0;
776 777
 	int i = 0;
777 778
 
778
-	p_geolist_t new = NULL;
779
+	p_lost_geolist_t new = NULL;
779 780
 
780 781
 	LM_DBG("parsing geolocation header value ...\n");
781 782
 
... ...
@@ -802,9 +803,9 @@ int lost_new_geoheader_list(p_geolist_t *list, str hdr)
802 803
 					len++;
803 804
 				}
804 805
 				if((*(ptr + len) == '>') && (len > 6)) {
805
-					new = (p_geolist_t)pkg_malloc(sizeof(s_geolist_t));
806
+					new = (p_lost_geolist_t)pkg_malloc(sizeof(s_lost_geolist_t));
806 807
 					if(new == NULL) {
807
-						LM_ERR("no more private memory\n");
808
+						PKG_MEM_ERROR;
808 809
 					} else {
809 810
 
810 811
 						LM_DBG("\t[%.*s]\n", len + 1, cidptr);
... ...
@@ -844,9 +845,9 @@ int lost_new_geoheader_list(p_geolist_t *list, str hdr)
844 845
 					len++;
845 846
 				}
846 847
 				if((*(ptr + len) == '>') && (len > 10)) {
847
-					new = (p_geolist_t)pkg_malloc(sizeof(s_geolist_t));
848
+					new = (p_lost_geolist_t)pkg_malloc(sizeof(s_lost_geolist_t));
848 849
 					if(new == NULL) {
849
-						LM_ERR("no more private memory\n");
850
+						PKG_MEM_ERROR;
850 851
 					} else {
851 852
 
852 853
 						LM_DBG("\t[%.*s]\n", len, urlptr);
... ...
@@ -885,10 +886,10 @@ int lost_new_geoheader_list(p_geolist_t *list, str hdr)
885 886
  * lost_parse_pidf(pidf, urn)
886 887
  * parses pidf and returns a new location object
887 888
  */
888
-p_loc_t lost_parse_pidf(str pidf, str urn)
889
+p_lost_loc_t lost_parse_pidf(str pidf, str urn)
889 890
 {
890 891
 
891
-	p_loc_t loc = NULL;
892
+	p_lost_loc_t loc = NULL;
892 893
 
893 894
 	xmlDocPtr doc = NULL;
894 895
 	xmlNodePtr root = NULL;
... ...
@@ -955,7 +956,7 @@ err:
955 956
  * parses locationResponse (pos|circle) and writes 
956 957
  * results to location object
957 958
  */
958
-int lost_parse_geo(xmlNodePtr node, p_loc_t loc)
959
+int lost_parse_geo(xmlNodePtr node, p_lost_loc_t loc)
959 960
 {
960 961
 	xmlNodePtr cur = NULL;
961 962
 
... ...
@@ -1021,7 +1022,7 @@ int lost_parse_geo(xmlNodePtr node, p_loc_t loc)
1021 1022
 	return 0;
1022 1023
 
1023 1024
 err:
1024
-	LM_ERR("no more private memory\n");
1025
+	PKG_MEM_ERROR;
1025 1026
 	return -1;
1026 1027
 }
1027 1028
 
... ...
@@ -1030,7 +1031,7 @@ err:
1030 1031
  * performs xpath expression on locationResponse and writes 
1031 1032
  * results (location-info child element) to location object
1032 1033
  */
1033
-int lost_xpath_location(xmlDocPtr doc, char *path, p_loc_t loc)
1034
+int lost_xpath_location(xmlDocPtr doc, char *path, p_lost_loc_t loc)
1034 1035
 {
1035 1036
 	xmlXPathObjectPtr result = NULL;
1036 1037
 	xmlNodeSetPtr nodes = NULL;
... ...
@@ -1251,7 +1252,7 @@ int lost_xpath_location(xmlDocPtr doc, char *path, p_loc_t loc)
1251 1252
 	return 0;
1252 1253
 
1253 1254
 err:
1254
-	LM_ERR("no more private memory\n");
1255
+	PKG_MEM_ERROR;
1255 1256
 	return -1;
1256 1257
 }
1257 1258
 
... ...
@@ -1259,7 +1260,7 @@ err:
1259 1260
  * lost_parse_location_info(node, loc)
1260 1261
  * wrapper to call xpath or simple pos|circle parser (last resort)
1261 1262
  */
1262
-int lost_parse_location_info(xmlNodePtr root, p_loc_t loc)
1263
+int lost_parse_location_info(xmlNodePtr root, p_lost_loc_t loc)
1263 1264
 {
1264 1265
 	if(lost_xpath_location(root->doc, LOST_XPATH_GP, loc) == 0) {
1265 1266
 		return 0;
... ...
@@ -1353,7 +1354,7 @@ https://tools.ietf.org/html/rfc6753
1353 1354
 
1354 1355
 	doc = (char *)pkg_malloc((buffersize + 1) * sizeof(char));
1355 1356
 	if(doc == NULL) {
1356
-		LM_ERR("no more private memory\n");
1357
+		PKG_MEM_ERROR;
1357 1358
 		xmlFree(xmlbuff);
1358 1359
 		xmlFreeDoc(request);
1359 1360
 		return doc;
... ...
@@ -1375,7 +1376,7 @@ https://tools.ietf.org/html/rfc6753
1375 1376
  * lost_held_location_request(held, lgth)
1376 1377
  * assembles and returns locationRequest string (allocated in private memory)
1377 1378
  */
1378
-char *lost_held_location_request(p_held_t held, int *lgth)
1379
+char *lost_held_location_request(p_lost_held_t held, int *lgth)
1379 1380
 {
1380 1381
 	int buffersize = 0;
1381 1382
 
... ...
@@ -1464,7 +1465,7 @@ https://tools.ietf.org/html/rfc5985
1464 1465
 
1465 1466
 	doc = (char *)pkg_malloc((buffersize + 1) * sizeof(char));
1466 1467
 	if(doc == NULL) {
1467
-		LM_ERR("no more private memory\n");
1468
+		PKG_MEM_ERROR;
1468 1469
 		xmlFree(xmlbuff);
1469 1470
 		xmlFreeDoc(request);
1470 1471
 		return doc;
... ...
@@ -1486,7 +1487,7 @@ https://tools.ietf.org/html/rfc5985
1486 1487
  * lost_find_service_request(loc, lgth)
1487 1488
  * assembles and returns findService request string (allocated in private memory)
1488 1489
  */
1489
-char *lost_find_service_request(p_loc_t loc, int *lgth)
1490
+char *lost_find_service_request(p_lost_loc_t loc, int *lgth)
1490 1491
 {
1491 1492
 	int buffersize = 0;
1492 1493
 
... ...
@@ -1624,7 +1625,7 @@ https://tools.ietf.org/html/rfc5222
1624 1625
 
1625 1626
 	doc = (char *)pkg_malloc((buffersize + 1) * sizeof(char));
1626 1627
 	if(doc == NULL) {
1627
-		LM_ERR("no more private memory\n");
1628
+		PKG_MEM_ERROR;
1628 1629
 		xmlFree(xmlbuff);
1629 1630
 		xmlFreeDoc(request);
1630 1631
 		return doc;
... ...
@@ -91,7 +91,7 @@ typedef struct LOC
91 91
 	int radius;		 /* geo radius (findServiceRequest) */
92 92
 	int recursive;	 /* recursion true|false (findServiceRequest)*/
93 93
 	int boundary;	 /* boundary ref|value (findServiceRequest)*/
94
-} s_loc_t, *p_loc_t;
94
+} s_lost_loc_t, *p_lost_loc_t;
95 95
 
96 96
 typedef struct HELD
97 97
 {
... ...
@@ -99,7 +99,7 @@ typedef struct HELD
99 99
 	char *type;		/* location type (locationRequest) */
100 100
 	int time;		/* response time (locationRequest) */
101 101
 	int exact;		/* exact true|false (locationRequest)*/
102
-} s_held_t, *p_held_t;
102
+} s_lost_held_t, *p_lost_held_t;
103 103
 
104 104
 typedef enum GEOTYPE
105 105
 {
... ...
@@ -108,32 +108,32 @@ typedef enum GEOTYPE
108 108
 	HTTP,		 /* http uri */
109 109
 	HTTPS,		 /* https uri */
110 110
 	UNKNOWN = -1 /* unknown */
111
-} geotype_t;
111
+} lost_geotype_t;
112 112
 
113 113
 typedef struct GEOLIST
114 114
 {
115
-	char *value;	/* geolocation header value */
116
-	char *param;	/* value parameter */
117
-	geotype_t type; /* type */
115
+	char *value;		 /* geolocation header value */
116
+	char *param;		 /* value parameter */
117
+	lost_geotype_t type; /* type */
118 118
 	struct GEOLIST *next;
119
-} s_geolist_t, *p_geolist_t;
119
+} s_lost_geolist_t, *p_lost_geolist_t;
120 120
 
121 121
 void lost_rand_str(char *, size_t);
122
-void lost_free_loc(p_loc_t *);
123
-void lost_free_held(p_held_t *);
122
+void lost_free_loc(p_lost_loc_t *);
123
+void lost_free_held(p_lost_held_t *);
124 124
 void lost_free_string(str *);
125
-void lost_free_geoheader_list(p_geolist_t *);
126
-void lost_reverse_geoheader_list(p_geolist_t *);
125
+void lost_free_geoheader_list(p_lost_geolist_t *);
126
+void lost_reverse_geoheader_list(p_lost_geolist_t *);
127 127
 
128
-int lost_parse_location_info(xmlNodePtr, p_loc_t);
129
-int lost_xpath_location(xmlDocPtr, char *, p_loc_t);
130
-int lost_parse_geo(xmlNodePtr, p_loc_t);
128
+int lost_parse_location_info(xmlNodePtr, p_lost_loc_t);
129
+int lost_xpath_location(xmlDocPtr, char *, p_lost_loc_t);
130
+int lost_parse_geo(xmlNodePtr, p_lost_loc_t);
131 131
 int lost_parse_host(const char *, str *, int *);
132
-int lost_new_geoheader_list(p_geolist_t *, str);
132
+int lost_new_geoheader_list(p_lost_geolist_t *, str);
133 133
 int lost_get_nameinfo(char *, str *, int);
134 134
 
135
-char *lost_find_service_request(p_loc_t, int *);
136
-char *lost_held_location_request(p_held_t, int *);
135
+char *lost_find_service_request(p_lost_loc_t, int *);
136
+char *lost_held_location_request(p_lost_held_t, int *);
137 137
 char *lost_held_post_request(int *, long, char *);
138 138
 char *lost_get_content(xmlNodePtr, const char *, int *);
139 139
 char *lost_get_property(xmlNodePtr, const char *, int *);
... ...
@@ -142,12 +142,12 @@ char *lost_get_pai_header(struct sip_msg *, int *);
142 142
 char *lost_get_childname(xmlNodePtr, const char *, int *);
143 143
 char *lost_trim_content(char *, int *);
144 144
 char *lost_copy_geoheader_value(char *, int);
145
-char *lost_get_geoheader_value(p_geolist_t, geotype_t, int *);
145
+char *lost_get_geoheader_value(p_lost_geolist_t, lost_geotype_t, int *);
146 146
 char *lost_copy_string(str, int *);
147 147
 
148
-p_loc_t lost_new_loc(str);
149
-p_loc_t lost_parse_pidf(str, str);
150
-p_held_t lost_new_held(str, str, int, int);
151
-p_geolist_t lost_get_geolocation_header(struct sip_msg *, int *);
148
+p_lost_loc_t lost_new_loc(str);
149
+p_lost_loc_t lost_parse_pidf(str, str);
150
+p_lost_held_t lost_new_held(str, str, int, int);
151
+p_lost_geolist_t lost_get_geolocation_header(struct sip_msg *, int *);
152 152
 
153 153
 #endif