Browse code

added sh_malloc.h

Jiri Kuthan authored on 03/12/2001 23:03:50
Showing 5 changed files
... ...
@@ -1,5 +1,6 @@
1 1
 #include "h_table.h"
2 2
 #include "../../dprint.h"
3
+#include "sh_malloc.h"
3 4
 
4 5
 
5 6
 /*   Frees the all the containes of a cell and the cell's body itself
... ...
@@ -13,13 +13,13 @@ struct entry;
13 13
 struct cell;
14 14
 struct timer;
15 15
 
16
+#include "sh_malloc.h"
17
+
16 18
 #include "timer.h"
17 19
 #include "lock.h"
18 20
 #include "sip_msg.h"
19 21
 
20 22
 
21
-#define sh_malloc( size )     malloc(size)
22
-#define sh_free( ptr )           free(ptr)
23 23
 
24 24
 /* defined in msg_parser.h
25 25
 #define get_cseq( p_msg)    ((struct cseq_body*)p_msg->cseq->parsed)
26 26
new file mode 100644
... ...
@@ -0,0 +1,34 @@
1
+#ifndef _SH_MALLOC_H
2
+#define _SH_MALLOC_H
3
+
4
+#ifdef MEM_DBG
5
+
6
+#include <stdlib.h>
7
+
8
+#define sh_malloc(size)		({ void *_p=malloc((size)); \
9
+				  printf("MEMDBG: malloc (%d): %p\n", (size), _p); \
10
+				  _p; })
11
+
12
+#define sh_free(ptr)		({ printf("MEMDBG: free: %p\n", (ptr)); free((ptr)); })
13
+
14
+/*
15
+#elif defined SHM_MEM
16
+
17
+#include "../../shm_mem.h"
18
+
19
+#define sh_malloc(size)		shm_malloc((size))
20
+#define sh_free(ptr)		shm_free((ptr))
21
+
22
+*/
23
+
24
+#else
25
+
26
+#include <stdlib.h>
27
+
28
+#define sh_malloc(size)		malloc((size))
29
+#define sh_free(ptr)		free((ptr))
30
+
31
+#endif
32
+
33
+
34
+#endif
... ...
@@ -3,8 +3,7 @@
3 3
 
4 4
 #include "../../msg_parser.h"
5 5
 
6
-#define sh_malloc( size )  malloc(size)
7
-#define sh_free( ptr )        free(ptr)
6
+#include "sh_malloc.h"
8 7
 
9 8
 
10 9
 struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg );
... ...
@@ -15,6 +15,8 @@ struct timer;
15 15
 struct entry;
16 16
 struct cell;
17 17
 
18
+#include "sh_malloc.h"
19
+
18 20
 #include "timer.h"
19 21
 #include "lock.h"
20 22
 #include "sip_msg.h"
... ...
@@ -22,8 +24,6 @@ struct cell;
22 24
 #define T_UNDEFINED 	( (struct cell*) -1 )
23 25
 #define T_NULL		( (struct cell*) 0 )
24 26
 
25
-#define sh_malloc( size )     malloc(size)
26
-#define sh_free( ptr )           free(ptr)
27 27
 /* already defined in msg_parser.h
28 28
 #define get_cseq( p_msg)    ((struct cseq_body*)p_msg->cseq->parsed)
29 29
 */