17 #ifndef ZenMemoryDebugH 18 #define ZenMemoryDebugH 22 #if defined(ZENLIB_DEBUG) 42 static MemoryDebug& Instance();
43 static bool g_IsShutdown;
44 void* Allocate(std::size_t Size,
const char* File,
int Line,
bool Array);
45 void Free(
void* Ptr,
bool Array);
46 void NextDelete(
const char*,
int Line);
59 typedef std::map<void*, TBlock> TBlockMap;
62 std::stack<TBlock> m_DeleteStack;
71 inline void*
operator new(std::size_t Size,
const char* File,
int Line)
73 return ZenLib::MemoryDebug::Instance().Allocate(Size, File, Line,
false);
75 inline void*
operator new[](std::size_t Size,
const char* File,
int Line)
77 return ZenLib::MemoryDebug::Instance().Allocate(Size, File, Line,
true);
80 inline void operator delete(
void* Ptr)
82 if (ZenLib::MemoryDebug::g_IsShutdown)
85 ZenLib::MemoryDebug::Instance().Free(Ptr,
false);
88 inline void operator delete[](
void* Ptr)
90 if (ZenLib::MemoryDebug::g_IsShutdown)
93 ZenLib::MemoryDebug::Instance().Free(Ptr,
true);
96 #if !defined(__BORLANDC__) // Borland does not support overloaded delete 97 inline void operator delete(
void* Ptr,
const char* File,
int Line)
99 ZenLib::MemoryDebug::Instance().NextDelete(File, Line);
100 ZenLib::MemoryDebug::Instance().Free(Ptr,
false);
103 inline void operator delete[](
void* Ptr,
const char* File,
int Line)
105 ZenLib::MemoryDebug::Instance().NextDelete(File, Line);
106 ZenLib::MemoryDebug::Instance().Free(Ptr,
true);
110 #if !defined(__MINGW32__) //TODO: Does not work on MinGW, don't know why 112 #define new new(__FILE__, __LINE__) 115 #define delete ZenLib::MemoryDebug::Instance().NextDelete(__FILE__, __LINE__), delete 117 #endif // __MINGW32__ 119 #endif // defined(ZENLIB_DEBUG) 121 #endif // ZenMemoryDebugH
Definition: BitStream.h:23