#include <pool_memory.h>
This memory manager allocates bloc of elements and free all the elements at the same time. Useful for temporary allocation.
Nevrax France
Definition at line 49 of file pool_memory.h.
Public Member Functions | |
T * | allocate () |
CPoolMemory (uint blockSize=10) | |
void | free () |
void | purge () |
Private Attributes | |
std::list< std::vector< T > > | _BlockList |
std::list< std::vector< T > >::iterator | _BlockPointer |
uint | _BlockSize |
|
Definition at line 57 of file pool_memory.h.
00058 { 00059 _BlockSize=blockSize; 00060 _BlockPointer=_BlockList.end(); 00061 } |
|
Definition at line 68 of file pool_memory.h.
00069 { 00070 // End of block ? 00071 if ( (_BlockPointer!=_BlockList.end()) && (_BlockPointer->size()>=_BlockSize) ) 00072 { 00073 // Get next block 00074 _BlockPointer++; 00075 } 00076 00077 // Out of memory ? 00078 if (_BlockPointer==_BlockList.end()) 00079 { 00080 // Add a block 00081 _BlockList.resize (_BlockList.size()+1); 00082 00083 // Pointer on the new block 00084 _BlockPointer=_BlockList.end (); 00085 _BlockPointer--; 00086 00087 // Reserve it 00088 _BlockPointer->reserve (_BlockSize); 00089 } 00090 00091 // Allocate 00092 _BlockPointer->resize (_BlockPointer->size()+1); 00093 00094 // Return the pointer 00095 return &*((_BlockPointer->end ()-1)); 00096 } |
|
Definition at line 101 of file pool_memory.h.
00102 { 00103 typename std::list< std::vector<T> >::iterator ite=_BlockList.begin(); 00104 while (ite!=_BlockList.end()) 00105 { 00106 // Clear the block 00107 ite->clear (); 00108 00109 // Check size in not zero 00110 nlassert (ite->capacity ()>0); 00111 00112 ite++; 00113 } 00114 // Pointer at the begining 00115 _BlockPointer=_BlockList.begin(); 00116 } |
|
Definition at line 121 of file pool_memory.h.
00122 { 00123 _BlockList.clear(); 00124 _BlockPointer=_BlockList.end(); 00125 } |
|
Definition at line 129 of file pool_memory.h. |
|
Definition at line 130 of file pool_memory.h. |
|
Definition at line 128 of file pool_memory.h. |