00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __CDS_MEMORY_H
00027 #define __CDS_MEMORY_H
00028
00029
00030
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034
00046
00047
00048
00049
00050
00051
00052
00053
00090 #ifdef TRACE_CDS_MEMORY
00091
00093 void *debug_malloc(int size, const char *file, int line);
00094
00096 void debug_free(void *block, const char *file, int line);
00097
00100 void *debug_malloc_ex(unsigned int size);
00101
00104 void debug_free_ex(void *block);
00105
00106
00107
00108 void cds_memory_trace(char *dst, int dst_len);
00109
00112 void cds_memory_trace_init();
00113
00114 #define cds_malloc(s) debug_malloc(s,__FILE__, __LINE__)
00115 #define cds_free(p) debug_free(p,__FILE__, __LINE__)
00116 #define cds_free_ptr debug_free_ex
00117 #define cds_malloc_ptr debug_malloc_ex
00118 #define cds_malloc_pkg(s) debug_malloc(s,__FILE__, __LINE__)
00119 #define cds_free_pkg(p) debug_free(p,__FILE__, __LINE__)
00120
00121 #else
00122
00123 #ifdef SER
00124
00125 #include <mem/mem.h>
00126 #include <mem/shm_mem.h>
00127
00128 void* shm_malloc_x(unsigned int size);
00129 void shm_free_x(void *ptr);
00130
00131 #define cds_malloc(s) shm_malloc(s)
00132 #define cds_free(p) shm_free(p)
00133 #define cds_malloc_ptr shm_malloc_x
00134 #define cds_free_ptr shm_free_x
00135 #define cds_malloc_pkg(s) pkg_malloc(s)
00136 #define cds_free_pkg(p) pkg_free(p)
00137
00138 #else
00139
00140 #include <stdlib.h>
00141
00142 #define cds_malloc(s) malloc(s)
00143 #define cds_free(p) free(p)
00144 #define cds_malloc_ptr malloc
00145 #define cds_free_ptr free
00146 #define cds_malloc_pkg(s) malloc(s)
00147 #define cds_free_pkg(p) free(p)
00148
00149 #endif
00150
00151 #endif
00152
00153 #ifdef __cplusplus
00154 }
00155 #endif
00156
00160 #endif
00161