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
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef _LALMALLOC_H
00052 #define _LALMALLOC_H
00053
00054 #include <stddef.h>
00055 #include <lal/LALRCSID.h>
00056 #include <lal/LALConfig.h>
00057
00058 #ifdef __cplusplus
00059 extern "C" {
00060 #endif
00061
00062
00063 NRCSID( LALMALLOCH, "$Id: LALMalloc.h,v 1.4 2007/06/08 14:41:52 bema Exp $" );
00064
00065 void *XLALMalloc( size_t n );
00066 void *XLALMallocLong( size_t n, const char *file, int line );
00067 void *XLALCalloc( size_t m, size_t n );
00068 void *XLALCallocLong( size_t m, size_t n, const char *file, int line );
00069 void *XLALRealloc( void *p, size_t n );
00070 void *XLALReallocLong( void *p, size_t n, const char *file, int line );
00071 void XLALFree( void *p );
00072 #define XLALMalloc( n ) XLALMallocLong( n, __FILE__, __LINE__ )
00073 #define XLALCalloc( m, n ) XLALCallocLong( m, n, __FILE__, __LINE__ )
00074 #define XLALRealloc( p, n ) XLALReallocLong( p, n, __FILE__, __LINE__ )
00075
00076 #if defined NDEBUG || defined LAL_NDEBUG
00077
00078 #define LALMalloc malloc
00079 #define LALMallocShort malloc
00080 #define LALMallocLong( n, file, line ) malloc( n )
00081 #define LALCalloc calloc
00082 #define LALCallocShort calloc
00083 #define LALCallocLong( m, n, file, line ) calloc( m, n )
00084 #define LALRealloc realloc
00085 #define LALReallocShort realloc
00086 #define LALReallocLong( p, n, file, line ) realloc( p, n )
00087 #define LALFree free
00088 #define LALCheckMemoryLeaks()
00089
00090 #else
00091
00092 #define LALMalloc( n ) LALMallocLong( n, __FILE__, __LINE__ )
00093 #define LALCalloc( m, n ) LALCallocLong( m, n, __FILE__, __LINE__ )
00094 #define LALRealloc( p, n ) LALReallocLong( p, n, __FILE__, __LINE__ )
00095
00096
00097
00098 extern char *lalMemDbgArgPtr;
00099 extern char *lalMemDbgRetPtr;
00100 extern char *lalMemDbgPtr;
00101 extern char *lalMemDbgUsrPtr;
00102 extern void **lalMemDbgUsrHndl;
00103 extern int lalIsMemDbgArgPtr;
00104 extern int lalIsMemDbgRetPtr;
00105 extern int lalIsMemDbgPtr;
00106
00107
00108 void *
00109 LALMallocShort( size_t n );
00110
00111 void *
00112 LALMallocLong( size_t n, const char *file, int line );
00113
00114 void
00115 LALFree( void *p );
00116
00117 void *
00118 LALCallocShort( size_t m, size_t n );
00119
00120 void *
00121 LALCallocLong( size_t m, size_t n, const char *file, int line );
00122
00123 void *
00124 LALReallocShort( void *p, size_t n );
00125
00126 void *
00127 LALReallocLong( void *p, size_t n, const char *file, int line );
00128
00129 void
00130 LALCheckMemoryLeaks( void );
00131
00132 #endif
00133
00134 #ifdef __cplusplus
00135 }
00136 #endif
00137
00138 #endif