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
00036 class PG_API pgMemMgr
00037 {
00038 public:
00039 pgDefineException(ExceptionInvalidArgument);
00040 pgDefineException(ExceptionInvalidCall);
00041 pgDefineException(ExceptionInvalidSizeOfType);
00042 pgDefineException(ExceptionInvalidVersionOfHeader);
00043 pgDefineException(ExceptionNotInitialized);
00044
00045 static void memset(void* buf, u8 value, u32 size);
00046 static void memcpy(void* dest, const void* src, u32 size);
00047
00048 static bool isCreated();
00049 static void createFirst(u32 pogolyn_version = POGOLYN_VERSION);
00050 static void destroyLast();
00051
00052 static u32 getCurUsedMemorySize();
00053 static u32 getMaxUsedMemorySize();
00054
00055 static const void* getFirstMemoryBlockN();
00056 static const void* getNextMemoryBlockN(const void* ptr);
00057 static const char* getMemoryBlockName(const void* ptr);
00058 static u32 getMemoryBlockSize(const void* ptr);
00059 static u32 getMemoryBlockArraySize(const void* ptr);
00060 static u32 getMemoryBlockHeaderSize();
00061
00062 static void* mallocForSystem(u32 size, u32 array_size, const char* name);
00063 static void* reallocForSystem(void* ptr, u32 size, u32 array_size, const char* name);
00064 static void freeForSystem(void* ptr);
00065 static void* allocTempBufferForSystem(u32 size);
00066 static u32 getTempBufferSizeForSystem();
00067
00068 private:
00069 static const u32 INITIAL_TEMP_BUFFER_SIZE = 1024;
00070
00071 struct MemoryBlockHeader
00072 {
00073 MemoryBlockHeader* prev;
00074 MemoryBlockHeader* next;
00075 const char* name;
00076 u32 size;
00077 u32 array_size;
00078 };
00079
00080 pgMemMgr();
00081 ~pgMemMgr();
00082 void operator=(const pgMemMgr&);
00083
00084 static pgMemMgr* instance();
00085
00086 MemoryBlockHeader m_mbh_start;
00087 MemoryBlockHeader m_mbh_end;
00088 u32 m_cur_used_memory_size;
00089 u32 m_max_used_memory_size;
00090 void* m_temp_buf;
00091 u32 m_temp_buf_size;
00092
00093 static pgMemMgr* m_instance;
00094 };