17#ifndef ZenMemoryDebugH
18#define ZenMemoryDebugH
22#if defined(ZENLIB_DEBUG)
44 static MemoryDebug& Instance();
45 static bool g_IsShutdown;
46 void* Allocate(std::size_t Size,
const char* File,
int Line,
bool Array);
47 void Free(
void* Ptr,
bool Array);
48 void NextDelete(
const char*,
int Line);
61 typedef std::map<void*, TBlock> TBlockMap;
64 std::stack<TBlock> m_DeleteStack;
73inline void*
operator new(std::size_t Size,
const char* File,
int Line)
75 return ZenLib::MemoryDebug::Instance().Allocate(Size, File, Line,
false);
77inline void*
operator new[](std::size_t Size,
const char* File,
int Line)
79 return ZenLib::MemoryDebug::Instance().Allocate(Size, File, Line,
true);
82inline void operator delete(
void* Ptr)
84 if (ZenLib::MemoryDebug::g_IsShutdown)
87 ZenLib::MemoryDebug::Instance().Free(Ptr,
false);
90inline void operator delete[](
void* Ptr)
92 if (ZenLib::MemoryDebug::g_IsShutdown)
95 ZenLib::MemoryDebug::Instance().Free(Ptr,
true);
98#if !defined(__BORLANDC__)
99inline void operator delete(
void* Ptr,
const char* File,
int Line)
101 ZenLib::MemoryDebug::Instance().NextDelete(File, Line);
102 ZenLib::MemoryDebug::Instance().Free(Ptr,
false);
105inline void operator delete[](
void* Ptr,
const char* File,
int Line)
107 ZenLib::MemoryDebug::Instance().NextDelete(File, Line);
108 ZenLib::MemoryDebug::Instance().Free(Ptr,
true);
112#if !defined(__MINGW32__)
114 #define new new(__FILE__, __LINE__)
117 #define delete ZenLib::MemoryDebug::Instance().NextDelete(__FILE__, __LINE__), delete
Definition: BitStream.h:24