Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

MyMem.h

Go to the documentation of this file.
00001 /*
00002  *  CUnit - A Unit testing framework library for C.
00003  *  Copyright (C) 2001  Anil Kumar
00004  *  Copyright (C) 2004  Anil Kumar, Jerry St.Clair
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Library General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Library General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Library General Public
00017  *  License along with this library; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /*
00022  *  Contains Memory Related Defines to use internal routines to detect Memory Leak
00023  *  in Debug Versions
00024  *
00025  *  Created By     : Anil Kumar on ...(18 June 2002)
00026  *  Last Modified  : 18/Jun/2002
00027  *  Comment        : Memory Debug Functions
00028  *  EMail          : aksaharan@yahoo.com
00029  *
00030  *  Modified       : 17-Jul-2004 (JDS)
00031  *  Comment        : New interface for global function names.
00032  *  EMail          : jds2@users.sourceforge.net
00033  *
00034  *  Modified       : 5-Sep-2004 (JDS)
00035  *  Comment        : Added internal test interface.
00036  *  EMail          : jds2@users.sourceforge.net
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  /*  _CUNIT_MYMEM_H  */
00113 

Generated on Thu Apr 28 12:36:09 2005 for CUnit by  doxygen 1.3.9.1