00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GE_RAM_H
00023 #define GE_RAM_H
00024
00025 #include "basetype.h"
00026
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030
00031 typedef int (* geRam_CriticalCallbackFunction)(void);
00032
00033
00034
00035
00036
00037 GENESISAPI geRam_CriticalCallbackFunction geRam_SetCriticalCallback
00038 (
00039 geRam_CriticalCallbackFunction callback
00040 );
00041
00042
00043
00044
00045
00046
00047 GENESISAPI int geRam_EnableCriticalCallback(int add);
00048
00049
00050
00051
00052
00053
00054
00055
00056 #ifndef NDEBUG
00057
00058 #define geRam_Allocate(size) _geRam_DebugAllocate(size, __FILE__, __LINE__)
00059
00060
00061 GENESISAPI void* _geRam_DebugAllocate(uint32 size, const char* pFile, int line);
00062
00063 #else
00064
00065 GENESISAPI void *geRam_Allocate(uint32 size);
00066
00067 #endif
00068
00069
00070
00071
00072 GENESISAPI void geRam_Free_(void *ptr);
00073
00074 extern void *StupidUnusedPointer;
00075
00076
00077
00078 #define geRam_Free(xxx) geRam_Free_(xxx) ,(xxx)=NULL, StupidUnusedPointer=(xxx)
00079
00080
00081
00082
00083
00084
00085 #ifndef NDEBUG
00086
00087 #define geRam_Realloc(ptr, newsize) _geRam_DebugRealloc(ptr, newsize, __FILE__, __LINE__)
00088
00089
00090 GENESISAPI void* _geRam_DebugRealloc(void* ptr, uint32 size, const char* pFile, int line);
00091
00092 #else
00093
00094 GENESISAPI void *geRam_Realloc(void *ptr,uint32 newsize);
00095
00096 #endif
00097
00098 #ifndef NDEBUG
00099
00100 GENESISAPI void geRam_ReportAllocations(void);
00101
00102 #else
00103
00104 #define geRam_ReportAllocations()
00105
00106 #endif
00107
00108 #ifndef NDEBUG
00109 extern int32 geRam_CurrentlyUsed;
00110 extern int32 geRam_NumberOfAllocations;
00111 extern int32 geRam_MaximumUsed;
00112 extern int32 geRam_MaximumNumberOfAllocations;
00113
00114 GENESISAPI void geRam_AddAllocation(int n,uint32 size);
00115 #else
00116 #define geRam_AddAllocation(n,s)
00117 #endif
00118
00119
00120 GENESISAPI void * geRam_AllocateClear(uint32 size);
00121
00122 #define GE_RAM_ALLOCATE_STRUCT(type) (type *)geRam_Allocate (sizeof (type))
00123 #define GE_RAM_ALLOCATE_ARRAY(type,count) (type *)geRam_Allocate (sizeof (type) * (count))
00124
00125 #ifndef NDEBUG
00126 #define GE_RAM_REALLOC_ARRAY(ptr,type,count) (type *)geRam_Realloc( (ptr), sizeof(type) * (count) );{type *XX=(ptr);}
00127 #else
00128 #define GE_RAM_REALLOC_ARRAY(ptr,type,count) (type *)geRam_Realloc( (ptr), sizeof(type) * (count) )
00129 #endif
00130
00131 #ifndef NDEBUG
00132 geBoolean geRam_IsValidPtr(void *ptr);
00133 #endif
00134
00135 #ifdef __cplusplus
00136 }
00137 #endif
00138
00139 #endif
00140