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