Browse code

- replaced all mallocs/frees w/ pkg_malloc/pkg_free - minor lock_dealloc warning fixes

Andrei Pelinescu-Onciul authored on 19/03/2003 18:41:58
Showing 17 changed files
... ...
@@ -30,6 +30,7 @@
30 30
  * 2003-01-29  removed scratchpad (jiri)
31 31
  * 2003-03-19  fixed set* len calculation bug & simplified a little the code
32 32
  *              (should be a little faster now) (andrei)
33
+ *             replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
33 34
  */
34 35
 
35 36
 
... ...
@@ -142,7 +143,7 @@ int do_action(struct action* a, struct sip_msg* msg)
142 142
 				ret=forward_request(msg, p, proto);
143 143
 				/*free_uri(&uri); -- no longer needed, in sip_msg*/
144 144
 				free_proxy(p); /* frees only p content, not p itself */
145
-				free(p);
145
+				pkg_free(p);
146 146
 				if (ret>=0) ret=1;
147 147
 			}else if ((a->p1_type==PROXY_ST) && (a->p2_type==NUMBER_ST)){
148 148
 				ret=forward_request(msg,(struct proxy_l*)a->p1.data, proto);
... ...
@@ -161,7 +162,8 @@ int do_action(struct action* a, struct sip_msg* msg)
161 161
 				ret=E_BUG;
162 162
 				break;
163 163
 			}
164
-			to=(union sockaddr_union*) malloc(sizeof(union sockaddr_union));
164
+			to=(union sockaddr_union*)
165
+					pkg_malloc(sizeof(union sockaddr_union));
165 166
 			if (to==0){
166 167
 				LOG(L_ERR, "ERROR: do_action: "
167 168
 							"memory allocation failure\n");
... ...
@@ -199,7 +201,7 @@ int do_action(struct action* a, struct sip_msg* msg)
199 199
 				}
200 200
 #endif
201 201
 			}
202
-			free(to);
202
+			pkg_free(to);
203 203
 			if (ret<0){
204 204
 				p->errors++;
205 205
 				p->ok=0;
... ...
@@ -28,8 +28,9 @@
28 28
  *
29 29
  * History:
30 30
  * -------
31
- * 2001-01-29 src_port added (jiri)
32
- * 2001-01-23 mhomed added (jiri)
31
+ *  2003-01-29  src_port added (jiri)
32
+ *  2003-01-23  mhomed added (jiri)
33
+ *  2003-03-19  replaced all the mallocs/frees w/ pkg_malloc/pkg_free (andrei)
33 34
  */
34 35
 
35 36
 
... ...
@@ -37,12 +38,10 @@
37 37
 	#include "cfg.tab.h"
38 38
 	#include "dprint.h"
39 39
 	#include "globals.h"
40
+	#include "mem/mem.h"
40 41
 	#include <string.h>
41 42
 	#include <stdlib.h>
42 43
 
43
-#ifdef DEBUG_DMALLOC
44
-#include <dmalloc.h>
45
-#endif
46 44
 
47 45
 	/* states */
48 46
 	#define INITIAL_S		0
... ...
@@ -330,7 +329,7 @@ EAT_ABLE	[\ \t\b\r]
330 330
 										case STRING_S: 
331 331
 											LOG(L_CRIT, "ERROR: cfg. parser: unexpected EOF in"
332 332
 														" unclosed string\n");
333
-											if (tstr) {free(tstr); tstr=0;}
333
+											if (tstr) {pkg_free(tstr);tstr=0;}
334 334
 											break;
335 335
 										case COMMENT_S:
336 336
 											LOG(L_CRIT, "ERROR: cfg. parser: unexpected EOF:"
... ...
@@ -356,12 +355,12 @@ static char* addstr(char * src, char ** dest)
356 356
 	}else{
357 357
 		len1=strlen(*dest);
358 358
 		len2=strlen(src);
359
-		tmp=malloc(len1+len2+1);
359
+		tmp=pkg_malloc(len1+len2+1);
360 360
 		if (tmp==0) goto error;
361 361
 		memcpy(tmp, *dest, len1);
362 362
 		memcpy(tmp+len1, src, len2);
363 363
 		tmp[len1+len2]=0;
364
-		free(*dest);
364
+		pkg_free(*dest);
365 365
 		*dest=tmp;
366 366
 	}
367 367
 	return *dest;
... ...
@@ -28,8 +28,9 @@
28 28
  *
29 29
  * History:
30 30
  * ---------
31
- * 2003-01-29 src_port added (jiri)
32
- * 2003-01-23 mhomed added (jiri)
31
+ * 2003-01-29  src_port added (jiri)
32
+ * 2003-01-23  mhomed added (jiri)
33
+ * 2003-03-19  replaced all mallocs/frees with pkg_malloc/pkg_free (andrei)
33 34
  */
34 35
 
35 36
 
... ...
@@ -222,7 +223,7 @@ listen_id:	ip			{	tmp=ip_addr2a($1);
222 222
 										"addresss.\n");
223 223
 								$$=0;
224 224
 							}else{
225
-								$$=malloc(strlen(tmp)+1);
225
+								$$=pkg_malloc(strlen(tmp)+1);
226 226
 								if ($$==0){
227 227
 									LOG(L_CRIT, "ERROR: cfg. parser: out of "
228 228
 											"memory.\n");
... ...
@@ -231,7 +232,7 @@ listen_id:	ip			{	tmp=ip_addr2a($1);
231 231
 								}
232 232
 							}
233 233
 						}
234
-		 |	ID			{	$$=malloc(strlen($1)+1);
234
+		 |	ID			{	$$=pkg_malloc(strlen($1)+1);
235 235
 		 					if ($$==0){
236 236
 									LOG(L_CRIT, "ERROR: cfg. parser: out of "
237 237
 											"memory.\n");
... ...
@@ -239,7 +240,7 @@ listen_id:	ip			{	tmp=ip_addr2a($1);
239 239
 									strncpy($$, $1, strlen($1)+1);
240 240
 							}
241 241
 						}
242
-		 |	STRING			{	$$=malloc(strlen($1)+1);
242
+		 |	STRING			{	$$=pkg_malloc(strlen($1)+1);
243 243
 		 					if ($$==0){
244 244
 									LOG(L_CRIT, "ERROR: cfg. parser: out of "
245 245
 											"memory.\n");
... ...
@@ -247,7 +248,7 @@ listen_id:	ip			{	tmp=ip_addr2a($1);
247 247
 									strncpy($$, $1, strlen($1)+1);
248 248
 							}
249 249
 						}
250
-		 |	host		{	$$=malloc(strlen($1)+1);
250
+		 |	host		{	$$=pkg_malloc(strlen($1)+1);
251 251
 		 					if ($$==0){
252 252
 									LOG(L_CRIT, "ERROR: cfg. parser: out of "
253 253
 											"memory.\n");
... ...
@@ -257,7 +258,7 @@ listen_id:	ip			{	tmp=ip_addr2a($1);
257 257
 						}
258 258
 	;
259 259
 
260
-id_lst:	  listen_id	{	$$=malloc(sizeof(struct id_list));
260
+id_lst:	  listen_id	{	$$=pkg_malloc(sizeof(struct id_list));
261 261
 						if ($$==0){
262 262
 							LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
263 263
 						}else{
... ...
@@ -266,7 +267,7 @@ id_lst:	  listen_id	{	$$=malloc(sizeof(struct id_list));
266 266
 						}
267 267
 					}
268 268
 		| listen_id id_lst	{
269
-						$$=malloc(sizeof(struct id_list));
269
+						$$=pkg_malloc(sizeof(struct id_list));
270 270
 						if ($$==0){
271 271
 							LOG(L_CRIT,"ERROR: cfg. parser: out of memory.\n");
272 272
 						}else{
... ...
@@ -328,8 +329,8 @@ assign_stm:	DEBUG EQUAL NUMBER { debug=$3; }
328 328
 		| LISTEN EQUAL id_lst {
329 329
 							for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next){
330 330
 								if (sock_no < MAX_LISTEN){
331
-									sock_info[sock_no].name.s=
332
-										(char*)malloc(strlen(lst_tmp->s)+1);
331
+									sock_info[sock_no].name.s=(char*)
332
+											pkg_malloc(strlen(lst_tmp->s)+1);
333 333
 									if (sock_info[sock_no].name.s==0){
334 334
 										LOG(L_CRIT, "ERROR: cfg. parser:"
335 335
 													" out of memory.\n");
... ...
@@ -386,7 +387,8 @@ ip:		 ipv4  { $$=$1; }
386 386
 		;
387 387
 
388 388
 ipv4:	NUMBER DOT NUMBER DOT NUMBER DOT NUMBER { 
389
-											$$=malloc(sizeof(struct ip_addr));
389
+											$$=pkg_malloc(
390
+													sizeof(struct ip_addr));
390 391
 											if ($$==0){
391 392
 												LOG(L_CRIT, "ERROR: cfg. "
392 393
 													"parser: out of memory.\n"
... ...
@@ -419,7 +421,7 @@ ipv4:	NUMBER DOT NUMBER DOT NUMBER DOT NUMBER {
419 419
 	;
420 420
 
421 421
 ipv6:	IPV6ADDR {
422
-					$$=malloc(sizeof(struct ip_addr));
422
+					$$=pkg_malloc(sizeof(struct ip_addr));
423 423
 					if ($$==0){
424 424
 						LOG(L_CRIT, "ERROR: cfg. parser: out of memory.\n");
425 425
 					}else{
... ...
@@ -611,7 +613,7 @@ ipnet:	ip SLASH ip	{ $$=mk_net($1, $3); }
611 611
 	;
612 612
 
613 613
 host:	ID				{ $$=$1; }
614
-	| host DOT ID		{ $$=(char*)malloc(strlen($1)+1+strlen($3)+1);
614
+	| host DOT ID		{ $$=(char*)pkg_malloc(strlen($1)+1+strlen($3)+1);
615 615
 						  if ($$==0){
616 616
 						  	LOG(L_CRIT, "ERROR: cfg. parser: memory allocation"
617 617
 										" failure while parsing host\n");
... ...
@@ -621,9 +623,9 @@ host:	ID				{ $$=$1; }
621 621
 						  	memcpy($$+strlen($1)+1, $3, strlen($3));
622 622
 						  	$$[strlen($1)+1+strlen($3)]=0;
623 623
 						  }
624
-						  free($1); free($3);
624
+						  pkg_free($1); pkg_free($3);
625 625
 						}
626
-	| host DOT error { $$=0; free($1); yyerror("invalid hostname"); }
626
+	| host DOT error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
627 627
 	;
628 628
 
629 629
 
... ...
@@ -53,7 +53,8 @@
53 53
  *
54 54
  * History:
55 55
  * --------
56
- * 2003-01-29 new built-in fifo commands: arg and pwd (jiri)
56
+ *  2003-01-29  new built-in fifo commands: arg and pwd (jiri)
57
+ *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
57 58
  */
58 59
 
59 60
 
... ...
@@ -117,7 +118,7 @@ int register_fifo_cmd(fifo_cmd f, char *cmd_name, void *param)
117 117
 		LOG(L_ERR, "ERROR: register_fifo_cmd: attempt to register synonyms\n");
118 118
 		return E_BUG;
119 119
 	}
120
-	new_cmd=malloc(sizeof(struct fifo_command));
120
+	new_cmd=pkg_malloc(sizeof(struct fifo_command));
121 121
 	if (new_cmd==0) {
122 122
 		LOG(L_ERR, "ERROR: register_fifo_cmd: out of mem\n");
123 123
 		return E_OUT_OF_MEM;
... ...
@@ -24,6 +24,11 @@
24 24
  * along with this program; if not, write to the Free Software 
25 25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 26
  */
27
+/*
28
+ * History:
29
+ * --------
30
+ *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
31
+ */
27 32
 
28 33
 
29 34
 #include <limits.h>
... ...
@@ -75,11 +80,12 @@ static int fixup_t_flag(void** param, int param_no)
75 75
 	DBG("DEBUG: fixing flag: %s\n", (char *) (*param));
76 76
 
77 77
 	if (param_no!=1) {
78
-		LOG(L_ERR, "ERROR: TM module: only parameter #1 for flags can be fixed\n");
78
+		LOG(L_ERR, "ERROR: TM module: only parameter #1 for flags can be"
79
+					" fixed\n");
79 80
 		return E_BUG;
80 81
 	};
81 82
 
82
-	if ( !(code = malloc( sizeof( unsigned int) )) ) return E_OUT_OF_MEM;
83
+	if ( !(code =pkg_malloc( sizeof( unsigned int) )) ) return E_OUT_OF_MEM;
83 84
 
84 85
 	*code = 0;
85 86
 	c = *param;
... ...
@@ -121,14 +127,14 @@ static int fixup_t_flag(void** param, int param_no)
121 121
 	}
122 122
 
123 123
 	/* free string */
124
-	free( *param );
124
+	pkg_free( *param );
125 125
 	/* fix now */
126 126
 	*param = code;
127 127
 	
128 128
 	return 0;
129 129
 
130 130
 error:
131
-	free( code );
131
+	pkg_free( code );
132 132
 	return E_CFG;
133 133
 }
134 134
 
... ...
@@ -26,14 +26,15 @@
26 26
  *
27 27
  * History:
28 28
  * -------
29
- * 2001-??-??  created by andrei
30
- * ????-??-??  lots of changes by a lot of people
31
- * 2003-01-23  support for determination of outbound interface added :
32
- *              get_out_socket (jiri)
33
- * 2003-01-24  reply to rport support added, contributed by
34
- *              Maxim Sobolev <sobomax@FreeBSD.org> and modified by andrei
35
- * 2003-02-11  removed calls to upd_send & tcp_send & replaced them with
36
- *              calls to msg_send (andrei)
29
+ *  2001-??-??  created by andrei
30
+ *  ????-??-??  lots of changes by a lot of people
31
+ *  2003-01-23  support for determination of outbound interface added :
32
+ *               get_out_socket (jiri)
33
+ *  2003-01-24  reply to rport support added, contributed by
34
+ *               Maxim Sobolev <sobomax@FreeBSD.org> and modified by andrei
35
+ *  2003-02-11  removed calls to upd_send & tcp_send & replaced them with
36
+ *               calls to msg_send (andrei)
37
+ *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
37 38
  */
38 39
 
39 40
 
... ...
@@ -249,7 +250,7 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p, int proto)
249 249
 	buf=0;
250 250
 	id=0;
251 251
 	
252
-	to=(union sockaddr_union*)malloc(sizeof(union sockaddr_union));
252
+	to=(union sockaddr_union*)pkg_malloc(sizeof(union sockaddr_union));
253 253
 	if (to==0){
254 254
 		ser_error=E_OUT_OF_MEM;
255 255
 		LOG(L_ERR, "ERROR: forward_request: out of memory\n");
... ...
@@ -325,12 +326,12 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p, int proto)
325 325
 	STATS_TX_REQUEST(  msg->first_line.u.request.method_value );
326 326
 	
327 327
 	pkg_free(buf);
328
-	free(to);
328
+	pkg_free(to);
329 329
 	/* received_buf & line_buf will be freed in receive_msg by free_lump_list*/
330 330
 	return 0;
331 331
 
332 332
 error1:
333
-	free(to);
333
+	pkg_free(to);
334 334
 error:
335 335
 	if (buf) pkg_free(buf);
336 336
 	return -1;
... ...
@@ -435,7 +436,7 @@ int forward_reply(struct sip_msg* msg)
435 435
 		goto error;
436 436
 	}
437 437
 
438
-	to=(union sockaddr_union*)malloc(sizeof(union sockaddr_union));
438
+	to=(union sockaddr_union*)pkg_malloc(sizeof(union sockaddr_union));
439 439
 	if (to==0){
440 440
 		LOG(L_ERR, "ERROR: forward_reply: out of memory\n");
441 441
 		goto error;
... ...
@@ -474,11 +475,11 @@ int forward_reply(struct sip_msg* msg)
474 474
 			(unsigned short) msg->via2->port);
475 475
 
476 476
 	pkg_free(new_buf);
477
-	free(to);
477
+	pkg_free(to);
478 478
 skip:
479 479
 	return 0;
480 480
 error:
481 481
 	if (new_buf) pkg_free(new_buf);
482
-	if (to) free(to);
482
+	if (to) pkg_free(to);
483 483
 	return -1;
484 484
 }
... ...
@@ -27,6 +27,11 @@
27 27
  * along with this program; if not, write to the Free Software 
28 28
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29 29
  */
30
+/*
31
+ * History:
32
+ * --------
33
+ *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free
34
+ */
30 35
 
31 36
 
32 37
 #include <stdlib.h>
... ...
@@ -34,6 +39,7 @@
34 34
 
35 35
 #include "ip_addr.h"
36 36
 #include "dprint.h"
37
+#include "mem/mem.h"
37 38
 
38 39
 
39 40
 struct net* mk_net(struct ip_addr* ip, struct ip_addr* mask)
... ...
@@ -45,7 +51,7 @@ struct net* mk_net(struct ip_addr* ip, struct ip_addr* mask)
45 45
 				" (eg. ipv4/ipv6mask or ipv6/ipv4mask)\n");
46 46
 		goto error;
47 47
 	}
48
-	n=(struct net*)malloc(sizeof(struct net));
48
+	n=(struct net*)pkg_malloc(sizeof(struct net));
49 49
 	if (n==0){ 
50 50
 		LOG(L_CRIT, "ERROR: mk_net: memory allocation failure\n");
51 51
 		goto error;
... ...
@@ -68,7 +74,7 @@ struct net* mk_net_bitlen(struct ip_addr* ip, unsigned int bitlen)
68 68
 		LOG(L_CRIT, "ERROR: mk_net_bitlen: bad bitlen number %d\n", bitlen);
69 69
 		goto error;
70 70
 	}
71
-	n=(struct net*)malloc(sizeof(struct net));
71
+	n=(struct net*)pkg_malloc(sizeof(struct net));
72 72
 	if (n==0){
73 73
 		LOG(L_CRIT, "ERROR: mk_net_bitlen: memory allocation failure\n"); 
74 74
 		goto error;
... ...
@@ -60,7 +60,7 @@ Implements: (see also locking.h)
60 60
 #if defined(FAST_LOCK) || defined(USE_PTHREAD_MUTEX) || defined(USE_POSIX_SEM)
61 61
 /* simple locks*/
62 62
 #define lock_alloc() shm_malloc(sizeof(gen_lock_t))
63
-#define lock_dealloc(lock) shm_free(lock)
63
+#define lock_dealloc(lock) shm_free((void*)lock)
64 64
 /* lock sets */
65 65
 
66 66
 inline static lock_set_t* lock_set_alloc(int n)
... ...
@@ -82,7 +82,7 @@ inline static lock_set_t* lock_set_alloc(int n)
82 82
 
83 83
 /*simple locks*/
84 84
 #define lock_alloc() shm_malloc(sizeof(gen_lock_t))
85
-#define lock_dealloc(lock) shm_free(lock)
85
+#define lock_dealloc(lock) shm_free((void*)lock)
86 86
 /* lock sets */
87 87
 
88 88
 inline static lock_set_t* lock_set_alloc(int n)
... ...
@@ -26,8 +26,9 @@
26 26
  *
27 27
  * History:
28 28
  * -------
29
- * 2002-01-29 argc/argv globalized via my_{argc|argv} (jiri)
30
- * 2001-01-23 mhomed added (jiri)
29
+ * 2002-01-29  argc/argv globalized via my_{argc|argv} (jiri)
30
+ * 2003-01-23  mhomed added (jiri)
31
+ * 2003-03-19  replaced all malloc/frees w/ pkg_malloc/pkg_free (andrei)
31 32
  *
32 33
  */
33 34
 
... ...
@@ -947,7 +948,7 @@ int add_interfaces(char* if_name, int family, unsigned short port)
947 947
 	ifc.ifc_req=0;
948 948
 	for (size=10; ; size*=2){
949 949
 		ifc.ifc_len=size*sizeof(struct ifreq);
950
-		ifc.ifc_req=(struct ifreq*) malloc(size*sizeof(struct ifreq));
950
+		ifc.ifc_req=(struct ifreq*) pkg_malloc(size*sizeof(struct ifreq));
951 951
 		if (ifc.ifc_req==0){
952 952
 			fprintf(stderr, "memory allocation failure\n");
953 953
 			goto error;
... ...
@@ -961,7 +962,7 @@ int add_interfaces(char* if_name, int family, unsigned short port)
961 961
 														   len not changed*/
962 962
 		lastlen=ifc.ifc_len;
963 963
 		/* try a bigger array*/
964
-		free(ifc.ifc_req);
964
+		pkg_free(ifc.ifc_req);
965 965
 	}
966 966
 	
967 967
 	last=(char*)ifc.ifc_req+ifc.ifc_len;
... ...
@@ -1008,7 +1009,7 @@ int add_interfaces(char* if_name, int family, unsigned short port)
1008 1008
 					(struct sockaddr*)(p+(long)&((struct ifreq*)0)->ifr_addr));
1009 1009
 				if ((tmp=ip_addr2a(&addr))==0) goto error;
1010 1010
 				/* fill the strings*/
1011
-				sock_info[sock_no].name.s=(char*)malloc(strlen(tmp)+1);
1011
+				sock_info[sock_no].name.s=(char*)pkg_malloc(strlen(tmp)+1);
1012 1012
 				if(sock_info[sock_no].name.s==0){
1013 1013
 					fprintf(stderr, "Out of memory.\n");
1014 1014
 					goto error;
... ...
@@ -1036,11 +1037,11 @@ int add_interfaces(char* if_name, int family, unsigned short port)
1036 1036
 			ls_ifflags(ifr->ifr_name, family, options);
1037 1037
 			printf("\n");*/
1038 1038
 	}
1039
-	free(ifc.ifc_req); /*clean up*/
1039
+	pkg_free(ifc.ifc_req); /*clean up*/
1040 1040
 	close(s);
1041 1041
 	return  ret;
1042 1042
 error:
1043
-	if (ifc.ifc_req) free(ifc.ifc_req);
1043
+	if (ifc.ifc_req) pkg_free(ifc.ifc_req);
1044 1044
 	close(s);
1045 1045
 	return -1;
1046 1046
 }
... ...
@@ -1159,7 +1160,7 @@ int main(int argc, char** argv)
1159 1159
 					/* add a new addr. to our address list */
1160 1160
 					if (sock_no < MAX_LISTEN){
1161 1161
 						sock_info[sock_no].name.s=
1162
-										(char*)malloc(strlen(optarg)+1);
1162
+										(char*)pkg_malloc(strlen(optarg)+1);
1163 1163
 						if (sock_info[sock_no].name.s==0){
1164 1164
 							fprintf(stderr, "Out of memory.\n");
1165 1165
 							goto error;
... ...
@@ -1377,7 +1378,8 @@ try_again:
1377 1377
 				fprintf(stderr, "cannot determine hostname, try -l address\n");
1378 1378
 				goto error;
1379 1379
 			}
1380
-			sock_info[sock_no].name.s=(char*)malloc(strlen(myname.nodename)+1);
1380
+			sock_info[sock_no].name.s=
1381
+								(char*)pkg_malloc(strlen(myname.nodename)+1);
1381 1382
 			if (sock_info[sock_no].name.s==0){
1382 1383
 				fprintf(stderr, "Out of memory.\n");
1383 1384
 				goto error;
... ...
@@ -1395,7 +1397,7 @@ try_again:
1395 1395
 		if (add_interfaces(sock_info[r].name.s, AF_INET,
1396 1396
 					sock_info[r].port_no)!=-1){
1397 1397
 			/* success => remove current entry (shift the entire array)*/
1398
-			free(sock_info[r].name.s);
1398
+			pkg_free(sock_info[r].name.s);
1399 1399
 			memmove(&sock_info[r], &sock_info[r+1], 
1400 1400
 						(sock_no-r)*sizeof(struct socket_info));
1401 1401
 			sock_no--;
... ...
@@ -1427,7 +1429,7 @@ try_again:
1427 1427
 		  not have  enough space */
1428 1428
 		port_no_str_len=
1429 1429
 				(port_no_str_len<MAX_PORT_LEN)?port_no_str_len:MAX_PORT_LEN;
1430
-		sock_info[r].port_no_str.s=(char*)malloc(strlen(port_no_str)+1);
1430
+		sock_info[r].port_no_str.s=(char*)pkg_malloc(strlen(port_no_str)+1);
1431 1431
 		if (sock_info[r].port_no_str.s==0){
1432 1432
 			fprintf(stderr, "Out of memory.\n");
1433 1433
 			goto error;
... ...
@@ -1449,8 +1451,8 @@ try_again:
1449 1449
 				LOG(L_ERR, "ERROR: main: add_alias failed\n");
1450 1450
 			}
1451 1451
 			/* change the oficial name */
1452
-			free(sock_info[r].name.s);
1453
-			sock_info[r].name.s=(char*)malloc(strlen(he->h_name)+1);
1452
+			pkg_free(sock_info[r].name.s);
1453
+			sock_info[r].name.s=(char*)pkg_malloc(strlen(he->h_name)+1);
1454 1454
 			if (sock_info[r].name.s==0){
1455 1455
 				fprintf(stderr, "Out of memory.\n");
1456 1456
 				goto error;
... ...
@@ -1466,7 +1468,7 @@ try_again:
1466 1466
 		hostent2ip_addr(&sock_info[r].address, he, 0); /*convert to ip_addr 
1467 1467
 														 format*/
1468 1468
 		if ((tmp=ip_addr2a(&sock_info[r].address))==0) goto error;
1469
-		sock_info[r].address_str.s=(char*)malloc(strlen(tmp)+1);
1469
+		sock_info[r].address_str.s=(char*)pkg_malloc(strlen(tmp)+1);
1470 1470
 		if (sock_info[r].address_str.s==0){
1471 1471
 			fprintf(stderr, "Out of memory.\n");
1472 1472
 			goto error;
... ...
@@ -1527,9 +1529,9 @@ try_again:
1527 1527
 								sock_info[t].port_no);
1528 1528
 						
1529 1529
 				/* free space*/
1530
-				free(sock_info[t].name.s);
1531
-				free(sock_info[t].address_str.s);
1532
-				free(sock_info[t].port_no_str.s);
1530
+				pkg_free(sock_info[t].name.s);
1531
+				pkg_free(sock_info[t].address_str.s);
1532
+				pkg_free(sock_info[t].port_no_str.s);
1533 1533
 				/* shift the array*/
1534 1534
 				memmove(&sock_info[t], &sock_info[t+1], 
1535 1535
 							(sock_no-t)*sizeof(struct socket_info));
... ...
@@ -1575,7 +1577,7 @@ try_again:
1575 1575
 #ifdef SHM_MEM
1576 1576
 	pt=shm_malloc(sizeof(struct process_table)*process_count());
1577 1577
 #else
1578
-	pt=malloc(sizeof(struct process_table)*process_count());
1578
+	pt=pkg_malloc(sizeof(struct process_table)*process_count());
1579 1579
 #endif
1580 1580
 	if (pt==0){
1581 1581
 		fprintf(stderr, "ERROR: out  of memory\n");
... ...
@@ -25,11 +25,17 @@
25 25
  * along with this program; if not, write to the Free Software 
26 26
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27 27
  */
28
+/*
29
+ * History:
30
+ * --------
31
+ *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
32
+ */
28 33
 
29 34
 
30 35
 
31 36
 #include "str.h"
32 37
 #include "dprint.h"
38
+#include "mem/mem.h"
33 39
 
34 40
 
35 41
 
... ...
@@ -68,9 +74,9 @@ static inline int add_alias(char* name, int len, unsigned short port)
68 68
 	
69 69
 	if ((port) && grep_aliases(name,len, port)) return 0;
70 70
 	a=0;
71
-	a=(struct host_alias*)malloc(sizeof(struct host_alias));
71
+	a=(struct host_alias*)pkg_malloc(sizeof(struct host_alias));
72 72
 	if(a==0) goto error;
73
-	a->alias.s=(char*)malloc(len+1);
73
+	a->alias.s=(char*)pkg_malloc(len+1);
74 74
 	if (a->alias.s==0) goto error;
75 75
 	a->alias.len=len;
76 76
 	memcpy(a->alias.s, name, len);
... ...
@@ -81,7 +87,7 @@ static inline int add_alias(char* name, int len, unsigned short port)
81 81
 	return 1;
82 82
 error:
83 83
 	LOG(L_ERR, "ERROR: add_alias: memory allocation error\n");
84
-	if (a) free(a);
84
+	if (a) pkg_free(a);
85 85
 	return -1;
86 86
 }
87 87
 
... ...
@@ -31,6 +31,7 @@
31 31
   * History:
32 32
   * -------
33 33
   *  2003-02-13  all *proxy fucntions are now proto aware (andrei)
34
+  *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
34 35
   */
35 36
 
36 37
 
... ...
@@ -39,6 +40,7 @@
39 39
 #include "proxy.h"
40 40
 #include "error.h"
41 41
 #include "dprint.h"
42
+#include "mem/mem.h"
42 43
 
43 44
 #include <string.h>
44 45
 #include <stdlib.h>
... ...
@@ -52,9 +54,6 @@
52 52
 #include "ip_addr.h"
53 53
 #include "globals.h"
54 54
 
55
-#ifdef DEBUG_DMALLOC
56
-#include <dmalloc.h>
57
-#endif
58 55
 
59 56
 struct proxy_l* proxies=0;
60 57
 
... ...
@@ -86,7 +85,7 @@ static int hostent_cpy(struct hostent *dst, struct hostent* src)
86 86
 	/* start copying the host entry.. */
87 87
 	/* copy h_name */
88 88
 	len=strlen(src->h_name)+1;
89
-	dst->h_name=(char*)malloc(sizeof(char) * len);
89
+	dst->h_name=(char*)pkg_malloc(sizeof(char) * len);
90 90
 	if (dst->h_name) strncpy(dst->h_name,src->h_name, len);
91 91
 	else{
92 92
 		ser_error=ret=E_OUT_OF_MEM;
... ...
@@ -97,21 +96,21 @@ static int hostent_cpy(struct hostent *dst, struct hostent* src)
97 97
 	len=0;
98 98
 	if (src->h_aliases)
99 99
 		for (;src->h_aliases[len];len++);
100
-	dst->h_aliases=(char**)malloc(sizeof(char*)*(len+1));
100
+	dst->h_aliases=(char**)pkg_malloc(sizeof(char*)*(len+1));
101 101
 	if (dst->h_aliases==0){
102 102
 		ser_error=ret=E_OUT_OF_MEM;
103
-		free(dst->h_name);
103
+		pkg_free(dst->h_name);
104 104
 		goto error;
105 105
 	}
106 106
 	memset((void*)dst->h_aliases, 0, sizeof(char*) * (len+1) );
107 107
 	for (i=0;i<len;i++){
108 108
 		len2=strlen(src->h_aliases[i])+1;
109
-		dst->h_aliases[i]=(char*)malloc(sizeof(char)*len2);
109
+		dst->h_aliases[i]=(char*)pkg_malloc(sizeof(char)*len2);
110 110
 		if (dst->h_aliases==0){
111 111
 			ser_error=ret=E_OUT_OF_MEM;
112
-			free(dst->h_name);
113
-			for(r=0; r<i; r++)	free(dst->h_aliases[r]);
114
-			free(dst->h_aliases);
112
+			pkg_free(dst->h_name);
113
+			for(r=0; r<i; r++)	pkg_free(dst->h_aliases[r]);
114
+			pkg_free(dst->h_aliases);
115 115
 			goto error;
116 116
 		}
117 117
 		strncpy(dst->h_aliases[i], src->h_aliases[i], len2);
... ...
@@ -120,26 +119,26 @@ static int hostent_cpy(struct hostent *dst, struct hostent* src)
120 120
 	len=0;
121 121
 	if (src->h_addr_list)
122 122
 		for (;src->h_addr_list[len];len++);
123
-	dst->h_addr_list=(char**)malloc(sizeof(char*)*(len+1));
123
+	dst->h_addr_list=(char**)pkg_malloc(sizeof(char*)*(len+1));
124 124
 	if (dst->h_addr_list==0){
125 125
 		ser_error=ret=E_OUT_OF_MEM;
126
-		free(dst->h_name);
127
-		for(r=0; dst->h_aliases[r]; r++)	free(dst->h_aliases[r]);
128
-		free(dst->h_aliases[r]);
129
-		free(dst->h_aliases);
126
+		pkg_free(dst->h_name);
127
+		for(r=0; dst->h_aliases[r]; r++)	pkg_free(dst->h_aliases[r]);
128
+		pkg_free(dst->h_aliases[r]);
129
+		pkg_free(dst->h_aliases);
130 130
 		goto error;
131 131
 	}
132 132
 	memset((void*)dst->h_addr_list, 0, sizeof(char*) * (len+1) );
133 133
 	for (i=0;i<len;i++){
134
-		dst->h_addr_list[i]=(char*)malloc(sizeof(char)*src->h_length);
134
+		dst->h_addr_list[i]=(char*)pkg_malloc(sizeof(char)*src->h_length);
135 135
 		if (dst->h_addr_list[i]==0){
136 136
 			ser_error=ret=E_OUT_OF_MEM;
137
-			free(dst->h_name);
138
-			for(r=0; dst->h_aliases[r]; r++)	free(dst->h_aliases[r]);
139
-			free(dst->h_aliases[r]);
140
-			free(dst->h_aliases);
141
-			for (r=0; r<i;r++) free(dst->h_addr_list[r]);
142
-			free(dst->h_addr_list);
137
+			pkg_free(dst->h_name);
138
+			for(r=0; dst->h_aliases[r]; r++)	pkg_free(dst->h_aliases[r]);
139
+			pkg_free(dst->h_aliases[r]);
140
+			pkg_free(dst->h_aliases);
141
+			for (r=0; r<i;r++) pkg_free(dst->h_addr_list[r]);
142
+			pkg_free(dst->h_addr_list);
143 143
 			goto error;
144 144
 		}
145 145
 		memcpy(dst->h_addr_list[i], src->h_addr_list[i], src->h_length);
... ...
@@ -162,16 +161,16 @@ error:
162 162
 void free_hostent(struct hostent *dst)
163 163
 {
164 164
 	int r;
165
-	if (dst->h_name) free(dst->h_name);
165
+	if (dst->h_name) pkg_free(dst->h_name);
166 166
 	if (dst->h_aliases){
167
-		for(r=0; dst->h_aliases[r]; r++)	free(dst->h_aliases[r]);
168
-		free(dst->h_aliases[r]);
169
-		free(dst->h_aliases);
167
+		for(r=0; dst->h_aliases[r]; r++)	pkg_free(dst->h_aliases[r]);
168
+		pkg_free(dst->h_aliases[r]);
169
+		pkg_free(dst->h_aliases);
170 170
 	}
171 171
 	if (dst->h_addr_list){
172
-		for (r=0; dst->h_addr_list[r];r++) free(dst->h_addr_list[r]);
173
-		free(dst->h_addr_list[r]);
174
-		free(dst->h_addr_list);
172
+		for (r=0; dst->h_addr_list[r];r++) pkg_free(dst->h_addr_list[r]);
173
+		pkg_free(dst->h_addr_list[r]);
174
+		pkg_free(dst->h_addr_list);
175 175
 	}
176 176
 }
177 177
 
... ...
@@ -204,7 +203,7 @@ struct proxy_l* mk_proxy(str* name, unsigned short port, int proto)
204 204
 	struct proxy_l* p;
205 205
 	struct hostent* he;
206 206
 
207
-	p=(struct proxy_l*) malloc(sizeof(struct proxy_l));
207
+	p=(struct proxy_l*) pkg_malloc(sizeof(struct proxy_l));
208 208
 	if (p==0){
209 209
 		ser_error=E_OUT_OF_MEM;
210 210
 		LOG(L_CRIT, "ERROR: mk_proxy: memory allocation failure\n");
... ...
@@ -221,11 +220,11 @@ struct proxy_l* mk_proxy(str* name, unsigned short port, int proto)
221 221
 		ser_error=E_BAD_ADDRESS;
222 222
 		LOG(L_CRIT, "ERROR: mk_proxy: could not resolve hostname:"
223 223
 					" \"%.*s\"\n", name->len, name->s);
224
-		free(p);
224
+		pkg_free(p);
225 225
 		goto error;
226 226
 	}
227 227
 	if (hostent_cpy(&(p->host), he)!=0){
228
-		free(p);
228
+		pkg_free(p);
229 229
 		goto error;
230 230
 	}
231 231
 	p->ok=1;
... ...
@@ -242,7 +241,7 @@ struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port,
242 242
 {
243 243
 	struct proxy_l* p;
244 244
 
245
-	p=(struct proxy_l*) malloc(sizeof(struct proxy_l));
245
+	p=(struct proxy_l*) pkg_malloc(sizeof(struct proxy_l));
246 246
 	if (p==0){
247 247
 		LOG(L_CRIT, "ERROR: mk_proxy_from_ip: memory allocation failure\n");
248 248
 		goto error;
... ...
@@ -253,12 +252,12 @@ struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port,
253 253
 	p->proto=proto;
254 254
 	p->host.h_addrtype=ip->af;
255 255
 	p->host.h_length=ip->len;
256
-	p->host.h_addr_list=malloc(2*sizeof(char*));
256
+	p->host.h_addr_list=pkg_malloc(2*sizeof(char*));
257 257
 	if (p->host.h_addr_list==0) goto error;
258 258
 	p->host.h_addr_list[1]=0;
259
-	p->host.h_addr_list[0]=malloc(ip->len+1);
259
+	p->host.h_addr_list[0]=pkg_malloc(ip->len+1);
260 260
 	if (p->host.h_addr_list[0]==0){
261
-		free(p->host.h_addr_list);
261
+		pkg_free(p->host.h_addr_list);
262 262
 		goto error;
263 263
 	}
264 264
 
... ...
@@ -29,9 +29,10 @@
29 29
  *
30 30
  * History:
31 31
  * --------
32
- * 2003-02-28  scratchpad compatibility abandoned (jiri)
33
- * 2003-01-28  scratchpad removed, src_port introduced (jiri)
34
- * 2003-03-10  updated to the new module exports format (andrei)
32
+ *  2003-02-28  scratchpad compatibility abandoned (jiri)
33
+ *  2003-01-28  scratchpad removed, src_port introduced (jiri)
34
+ *  2003-03-10  updated to the new module exports format (andrei)
35
+ *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
35 36
  */
36 37
 
37 38
  
... ...
@@ -54,10 +55,8 @@
54 54
 #include "ip_addr.h"
55 55
 #include "resolve.h"
56 56
 #include "parser/parse_uri.h"
57
+#include "mem/mem.h"
57 58
 
58
-#ifdef DEBUG_DMALLOC
59
-#include <dmalloc.h>
60
-#endif
61 59
 
62 60
 /* main routing script table  */
63 61
 struct action* rlist[RT_NO];
... ...
@@ -98,7 +97,7 @@ static int fix_expr(struct expr* exp)
98 98
 	}else if (exp->type==ELEM_T){
99 99
 			if (exp->op==MATCH_OP){
100 100
 				if (exp->subtype==STRING_ST){
101
-					re=(regex_t*)malloc(sizeof(regex_t));
101
+					re=(regex_t*)pkg_malloc(sizeof(regex_t));
102 102
 					if (re==0){
103 103
 						LOG(L_CRIT, "ERROR: fix_expr: memory allocation"
104 104
 								" failure\n");
... ...
@@ -108,11 +107,11 @@ static int fix_expr(struct expr* exp)
108 108
 								REG_EXTENDED|REG_NOSUB|REG_ICASE) ){
109 109
 						LOG(L_CRIT, "ERROR: fix_expr : bad re \"%s\"\n",
110 110
 									(char*) exp->r.param);
111
-						free(re);
111
+						pkg_free(re);
112 112
 						return E_BAD_RE;
113 113
 					}
114 114
 					/* replace the string with the re */
115
-					free(exp->r.param);
115
+					pkg_free(exp->r.param);
116 116
 					exp->r.param=re;
117 117
 					exp->subtype=RE_ST;
118 118
 				}else if (exp->subtype!=RE_ST){
... ...
@@ -25,8 +25,11 @@
25 25
  * You should have received a copy of the GNU General Public License 
26 26
  * along with this program; if not, write to the Free Software 
27 27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
- *
29
- * 2003-01-29 src_port introduced (jiri)
28
+ */
29
+/* History:
30
+ * --------
31
+ *  2003-01-29  src_port introduced (jiri)
32
+ *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
30 33
  */
31 34
 
32 35
 
... ...
@@ -39,15 +42,13 @@
39 39
 
40 40
 #include "dprint.h"
41 41
 #include "ip_addr.h"
42
+#include "mem/mem.h"
42 43
 
43
-#ifdef DEBUG_DMALLOC
44
-#include <dmalloc.h>
45
-#endif
46 44
 
47 45
 struct expr* mk_exp(int op, struct expr* left, struct expr* right)
48 46
 {
49 47
 	struct expr * e;
50
-	e=(struct expr*)malloc(sizeof (struct expr));
48
+	e=(struct expr*)pkg_malloc(sizeof (struct expr));
51 49
 	if (e==0) goto error;
52 50
 	e->type=EXP_T;
53 51
 	e->op=op;
... ...
@@ -63,7 +64,7 @@ error:
63 63
 struct expr* mk_elem(int op, int subtype, int operand, void* param)
64 64
 {
65 65
 	struct expr * e;
66
-	e=(struct expr*)malloc(sizeof (struct expr));
66
+	e=(struct expr*)pkg_malloc(sizeof (struct expr));
67 67
 	if (e==0) goto error;
68 68
 	e->type=ELEM_T;
69 69
 	e->op=op;
... ...
@@ -82,7 +83,7 @@ struct action* mk_action(int type, int p1_type, int p2_type,
82 82
 											void* p1, void* p2)
83 83
 {
84 84
 	struct action* a;
85
-	a=(struct action*)malloc(sizeof(struct action));
85
+	a=(struct action*)pkg_malloc(sizeof(struct action));
86 86
 	if (a==0) goto  error;
87 87
 	memset(a,0,sizeof(struct action));
88 88
 	a->type=type;
... ...
@@ -29,12 +29,17 @@
29 29
  * along with this program; if not, write to the Free Software 
30 30
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
31 31
  */
32
+/* History:
33
+ * --------
34
+ *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
35
+ */
32 36
 
33 37
 
34 38
 #include <stdlib.h>
35 39
 #include "script_cb.h"
36 40
 #include "dprint.h"
37 41
 #include "error.h"
42
+#include "mem/mem.h"
38 43
 
39 44
 static struct script_cb *pre_cb=0;
40 45
 static struct script_cb *post_cb=0;
... ...
@@ -44,7 +49,7 @@ int register_script_cb( cb_function f, callback_t t, void *param )
44 44
 {
45 45
 	struct script_cb *new_cb;
46 46
 
47
-	new_cb=malloc(sizeof(struct script_cb));
47
+	new_cb=pkg_malloc(sizeof(struct script_cb));
48 48
 	if (new_cb==0) {
49 49
 		LOG(L_ERR, "ERROR: register_script_cb: out of memory\n");
50 50
 		return E_OUT_OF_MEM;
... ...
@@ -28,12 +28,14 @@
28 28
  * --------
29 29
  *  2003-03-10  switched to new module_exports format: updated find_export,
30 30
  *               find_export_param, find_module (andrei)
31
+ *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
31 32
  */
32 33
 
33 34
 
34 35
 #include "sr_module.h"
35 36
 #include "dprint.h"
36 37
 #include "error.h"
38
+#include "mem/mem.h"
37 39
 
38 40
 #include <dlfcn.h>
39 41
 #include <strings.h>
... ...
@@ -127,7 +129,7 @@ int register_module(struct module_exports* e, char* path, void* handle)
127 127
 	ret=-1;
128 128
 
129 129
 	/* add module to the list */
130
-	if ((mod=malloc(sizeof(struct sr_module)))==0){
130
+	if ((mod=pkg_malloc(sizeof(struct sr_module)))==0){
131 131
 		LOG(L_ERR, "load_module: memory allocation failure\n");
132 132
 		ret=E_OUT_OF_MEM;
133 133
 		goto error;
... ...
@@ -24,6 +24,10 @@
24 24
  * along with this program; if not, write to the Free Software 
25 25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 26
  */
27
+/* History:
28
+ * --------
29
+ *  2003-03-19  replaced all the mallocs/frees w/ pkg_malloc/pkg_free (andrei)
30
+ */
27 31
 
28 32
 
29 33
 #include "timer.h"
... ...
@@ -54,7 +58,7 @@ int init_timer()
54 54
 	/* in this case get_ticks won't work! */
55 55
 	LOG(L_INFO, "WARNING: no shared memory support compiled in"
56 56
 				" get_ticks won't work\n");
57
-	jiffies=malloc(sizeof(int));
57
+	jiffies=pkg_malloc(sizeof(int));
58 58
 #endif
59 59
 	if (jiffies==0){
60 60
 		LOG(L_CRIT, "ERROR: init_timer: could not init jiffies\n");
... ...
@@ -72,7 +76,7 @@ void destroy_timer()
72 72
 #ifdef SHM_MEM
73 73
 		shm_free(jiffies); jiffies=0;
74 74
 #else
75
-		free(jiffies); jiffies=0;
75
+		pkg_free(jiffies); jiffies=0;
76 76
 #endif
77 77
 	}
78 78
 }
... ...
@@ -85,7 +89,7 @@ int register_timer(timer_function f, void* param, unsigned int interval)
85 85
 {
86 86
 	struct sr_timer* t;
87 87
 
88
-	t=malloc(sizeof(struct sr_timer));
88
+	t=pkg_malloc(sizeof(struct sr_timer));
89 89
 	if (t==0){
90 90
 		LOG(L_ERR, "ERROR: register_timer: out of memory\n");
91 91
 		goto error;
... ...
@@ -26,8 +26,9 @@
26 26
  *
27 27
  * History
28 28
  * --------
29
- * 2003-01-28 packet zero-termination moved to receive_msg (jiri)
30
- * 2003-02-10 undoed the above changes (andrei)
29
+ *  2003-01-28  packet zero-termination moved to receive_msg (jiri)
30
+ *  2003-02-10  undoed the above changes (andrei)
31
+ *  2003-03-19  replaced all the mallocs/frees w/ pkg_malloc/pkg_free (andrei)
31 32
  */
32 33
 
33 34
 
... ...
@@ -52,9 +53,6 @@
52 52
 #include "mem/mem.h"
53 53
 #include "ip_addr.h"
54 54
 
55
-#ifdef DEBUG_DMALLOC
56
-#include <mem/dmalloc.h>
57
-#endif
58 55
 
59 56
 #ifdef DBG_MSG_QA
60 57
 /* message quality assurance -- frequently, bugs in ser have
... ...
@@ -212,7 +210,7 @@ int udp_init(struct socket_info* sock_info)
212 212
 
213 213
 	addr=&sock_info->su;
214 214
 /*
215
-	addr=(union sockaddr_union*)malloc(sizeof(union sockaddr_union));
215
+	addr=(union sockaddr_union*)pkg_malloc(sizeof(union sockaddr_union));
216 216
 	if (addr==0){
217 217
 		LOG(L_ERR, "ERROR: udp_init: out of memory\n");
218 218
 		goto error;
... ...
@@ -263,11 +261,11 @@ int udp_init(struct socket_info* sock_info)
263 263
 		goto error;
264 264
 	}
265 265
 
266
-/*	free(addr);*/
266
+/*	pkg_free(addr);*/
267 267
 	return 0;
268 268
 
269 269
 error:
270
-/*	if (addr) free(addr);*/
270
+/*	if (addr) pkg_free(addr);*/
271 271
 	return -1;
272 272
 }
273 273
 
... ...
@@ -287,7 +285,7 @@ int udp_rcv_loop()
287 287
 	struct receive_info ri;
288 288
 
289 289
 
290
-	from=(union sockaddr_union*) malloc(sizeof(union sockaddr_union));
290
+	from=(union sockaddr_union*) pkg_malloc(sizeof(union sockaddr_union));
291 291
 	if (from==0){
292 292
 		LOG(L_ERR, "ERROR: udp_rcv_loop: out of memory\n");
293 293
 		goto error;
... ...
@@ -350,12 +348,12 @@ int udp_rcv_loop()
350 350
 		
351 351
 	}
352 352
 	/*
353
-	if (from) free(from);
353
+	if (from) pkg_free(from);
354 354
 	return 0;
355 355
 	*/
356 356
 	
357 357
 error:
358
-	if (from) free(from);
358
+	if (from) pkg_free(from);
359 359
 	return -1;
360 360
 }
361 361