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
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef INC_MI32_MEMPOOL_H
00051 #define INC_MI32_MEMPOOL_H
00052
00053 #ifndef INC_MI32_STDDEFNS_H
00054 #include <mi32/stddefns.h>
00055 #endif
00056
00057 #ifdef MISYSTEMDLL
00058 #define CLASSLIBEXPORT MI_DLLCLASSEXPORT
00059 #else
00060 #define CLASSLIBEXPORT MI_DLLCLASSIMPORT
00061 #endif
00062
00063 #ifndef GENERATING_DOXYGEN_OUTPUT
00068 class CLASSLIBEXPORT MEMPOOLLOW {
00069 protected:
00070
00072 MEMPOOLLOW();
00073
00077 MEMPOOLLOW (
00078 INT32 SizeHint
00079 );
00080
00082 MEMPOOLLOW (
00083 const MEMPOOLLOW& rhs
00084 );
00085
00090 ~MEMPOOLLOW();
00091
00092
00093 MEMPOOLLOW& operator= (const MEMPOOLLOW& rhs);
00094
00099 ERRVALUE AllocLow (
00100 void** ptr,
00101 UINT32 size,
00102 bool bClear = false
00103 );
00104
00110 ERRVALUE ReallocLow (
00111 void** ptr,
00112 UINT32 size,
00113 bool bClear = false
00114 );
00115
00116 void SetSizeHintLow (
00117 UINT32 size
00118 );
00119
00125 static void FreeLow (
00126 void* ptr
00127 );
00128
00129
00130 private:
00131 #ifndef GENERATING_DOXYGEN_OUTPUT
00132 class PRIVDATA;
00133 class BUCKET;
00134 struct STATS {
00135 UINT32 TotalAlloc;
00136 UINT32 FreeSpace;
00137 };
00138
00139 PRIVDATA* m_priv;
00140 STATS* m_stats;
00141 #endif // GENERATING_DOXYGEN_OUTPUT
00142
00143 };
00144
00145 #endif
00146
00155 class MEMPOOL : public MEMPOOLLOW {
00156 public:
00158 MEMPOOL() {}
00159
00163 MEMPOOL (
00164 INT32 SizeHint
00165 ) :
00166 MEMPOOLLOW(SizeHint)
00167 {}
00168
00173 ~MEMPOOL() {}
00174
00186 template <class _CT> ERRVALUE Alloc (
00187 _CT*& ptr,
00188 UINT32 size,
00189 bool bClear = false
00190 ) {
00191 return (AllocLow((void**)&ptr, size, bClear));
00192 }
00193
00210 template <class _CT> ERRVALUE Realloc (
00211 _CT*& ptr,
00212 UINT32 size,
00213 bool bClear = false
00214 ) {
00215 return (ReallocLow((void**)&ptr, size, bClear));
00216 }
00217
00226 void SetSizeHint (
00227 UINT32 size
00228 ) {
00229 SetSizeHintLow(size);
00230 }
00231
00232
00241 template<class _CT> static void Free (
00242 _CT*& ptr
00243 ) {
00244 FreeLow(ptr);
00245 ptr = 0;
00246 }
00247
00248
00249 };
00250
00251
00252 #undef CLASSLIBEXPORT
00253
00254 #endif
00255
00256