00001
00002 #ifndef _CDEBUGMEMORYMANAGER
00003 #define _CDEBUGMEMORYMANAGER
00004 #include "libMRML/include/uses-declarations.h"
00005 #include <iostream>
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "libMRML/include/CMutex.h"
00028 typedef long CDebuggingMemoryManagerSize;
00029
00030
00031 #define MEMSIZE 20000000
00032
00039 struct lTChunk{
00040 public:
00042 lTChunk* mPrev;
00043
00045 lTChunk* mNext;
00046
00048 lTChunk* mPreceding;
00049
00051 lTChunk* mFollowing;
00052
00057 CDebuggingMemoryManagerSize mSize;
00058
00065 long mMagic;
00066 };
00067
00073 class CDebuggingMemoryManager{
00074 protected:
00075
00078 void FreeChunk(lTChunk* inChunk);
00079
00081 lTChunk* mFreeList;
00083 lTChunk* mUsedList;
00084
00086 lTChunk* mBuffer;
00087
00089 const long cMagic;
00091 const long cUnMagic;
00092
00094 long cVM;
00096 CMutex mMutex;
00097 public:
00098
00102 CDebuggingMemoryManager(const CDebuggingMemoryManagerSize inSize);
00103
00105 void* getMem(CDebuggingMemoryManagerSize inSize);
00106
00108 bool freeMem(void*);
00109
00111 bool isValid()const;
00112
00114 friend ostream& operator <<(ostream& outStream,
00115 const CDebuggingMemoryManager& inMem);
00116 };
00117
00119 ostream& operator<<(ostream& o, const CDebuggingMemoryManager& inMem);
00120
00122 extern CDebuggingMemoryManager gMemManager;
00123
00124 #endif