Kaynağa Gözat

added sh_malloc.h

Jiri Kuthan 24 yıl önce
ebeveyn
işleme
9a163c8f4c

+ 1 - 0
modules/tm/h_table.c

@@ -1,5 +1,6 @@
 #include "h_table.h"
 #include "h_table.h"
 #include "../../dprint.h"
 #include "../../dprint.h"
+#include "sh_malloc.h"
 
 
 
 
 /*   Frees the all the containes of a cell and the cell's body itself
 /*   Frees the all the containes of a cell and the cell's body itself

+ 2 - 2
modules/tm/h_table.h

@@ -13,13 +13,13 @@ struct entry;
 struct cell;
 struct cell;
 struct timer;
 struct timer;
 
 
+#include "sh_malloc.h"
+
 #include "timer.h"
 #include "timer.h"
 #include "lock.h"
 #include "lock.h"
 #include "sip_msg.h"
 #include "sip_msg.h"
 
 
 
 
-#define sh_malloc( size )     malloc(size)
-#define sh_free( ptr )           free(ptr)
 
 
 /* defined in msg_parser.h
 /* defined in msg_parser.h
 #define get_cseq( p_msg)    ((struct cseq_body*)p_msg->cseq->parsed)
 #define get_cseq( p_msg)    ((struct cseq_body*)p_msg->cseq->parsed)

+ 34 - 0
modules/tm/sh_malloc.h

@@ -0,0 +1,34 @@
+#ifndef _SH_MALLOC_H
+#define _SH_MALLOC_H
+
+#ifdef MEM_DBG
+
+#include <stdlib.h>
+
+#define sh_malloc(size)		({ void *_p=malloc((size)); \
+				  printf("MEMDBG: malloc (%d): %p\n", (size), _p); \
+				  _p; })
+
+#define sh_free(ptr)		({ printf("MEMDBG: free: %p\n", (ptr)); free((ptr)); })
+
+/*
+#elif defined SHM_MEM
+
+#include "../../shm_mem.h"
+
+#define sh_malloc(size)		shm_malloc((size))
+#define sh_free(ptr)		shm_free((ptr))
+
+*/
+
+#else
+
+#include <stdlib.h>
+
+#define sh_malloc(size)		malloc((size))
+#define sh_free(ptr)		free((ptr))
+
+#endif
+
+
+#endif

+ 1 - 2
modules/tm/sip_msg.h

@@ -3,8 +3,7 @@
 
 
 #include "../../msg_parser.h"
 #include "../../msg_parser.h"
 
 
-#define sh_malloc( size )  malloc(size)
-#define sh_free( ptr )        free(ptr)
+#include "sh_malloc.h"
 
 
 
 
 struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg );
 struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg );

+ 2 - 2
modules/tm/t_funcs.h

@@ -15,6 +15,8 @@ struct timer;
 struct entry;
 struct entry;
 struct cell;
 struct cell;
 
 
+#include "sh_malloc.h"
+
 #include "timer.h"
 #include "timer.h"
 #include "lock.h"
 #include "lock.h"
 #include "sip_msg.h"
 #include "sip_msg.h"
@@ -22,8 +24,6 @@ struct cell;
 #define T_UNDEFINED 	( (struct cell*) -1 )
 #define T_UNDEFINED 	( (struct cell*) -1 )
 #define T_NULL		( (struct cell*) 0 )
 #define T_NULL		( (struct cell*) 0 )
 
 
-#define sh_malloc( size )     malloc(size)
-#define sh_free( ptr )           free(ptr)
 /* already defined in msg_parser.h
 /* already defined in msg_parser.h
 #define get_cseq( p_msg)    ((struct cseq_body*)p_msg->cseq->parsed)
 #define get_cseq( p_msg)    ((struct cseq_body*)p_msg->cseq->parsed)
 */
 */