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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00051 #ifndef _CUNIT_MYMEM_H
00052 #define _CUNIT_MYMEM_H
00053
00054 #ifdef __cplusplus
00055 extern "C" {
00056 #endif
00057
00058 #ifdef MEMTRACE
00059 void* CU_calloc(size_t nmemb, size_t size, unsigned int uiLine, const char* szFileName);
00060 void* CU_malloc(size_t size, unsigned int uiLine, const char* szFileName);
00061 void CU_free(void *ptr, unsigned int uiLine, const char* szFileName);
00062 void* CU_realloc(void *ptr, size_t size, unsigned int uiLine, const char* szFileName);
00063 void CU_dump_memory_usage(const char*);
00064
00066 #define CU_CALLOC(x, y) CU_calloc((x), (y), __LINE__, __FILE__)
00067
00068 #define CU_MALLOC(x) CU_malloc((x), __LINE__, __FILE__)
00069
00070 #define CU_FREE(x) CU_free((x), __LINE__, __FILE__)
00071
00072 #define CU_REALLOC(x, y) CU_realloc((x), (y), __LINE__, __FILE__)
00073
00074 #define CU_CREATE_MEMORY_REPORT(x) CU_dump_memory_usage((x))
00075
00076 #define CU_DUMP_MEMORY_USAGE(x) CU_dump_memory_usage((x))
00077 #else
00078
00079 #define CU_CALLOC(x, y) calloc((x), (y))
00080
00081 #define CU_MALLOC(x) malloc((x))
00082
00083 #define CU_FREE(x) free((x))
00084
00085 #define CU_REALLOC(x, y) realloc((x), (y))
00086
00087 #define CU_CREATE_MEMORY_REPORT(x)
00088
00089 #define CU_DUMP_MEMORY_USAGE(x)
00090 #endif
00091
00092 #ifdef CUNIT_BUILD_TESTS
00093
00094 void test_cunit_deactivate_malloc(void);
00096 void test_cunit_activate_malloc(void);
00098 unsigned int test_cunit_get_n_memevents(void* pLocation);
00100 unsigned int test_cunit_get_n_allocations(void* pLocation);
00102 unsigned int test_cunit_get_n_deallocations(void* pLocation);
00103
00104 void test_cunit_MyMem(void);
00105 #endif
00106
00107
00108 #ifdef __cplusplus
00109 }
00110 #endif
00111
00112 #endif
00113