antioch-0.4.0
List of all members | Classes | Public Member Functions | Private Types | Private Attributes
tinyxml2::MemPoolT< SIZE > Class Template Reference

#include <tinyxml2.h>

Inheritance diagram for tinyxml2::MemPoolT< SIZE >:
tinyxml2::MemPool

Classes

struct  Block
 
union  Chunk
 

Public Member Functions

 MemPoolT ()
 
 ~MemPoolT ()
 
virtual int ItemSize () const
 
int CurrentAllocs () const
 
virtual void * Alloc ()
 
virtual void Free (void *mem)
 
void Trace (const char *name)
 

Private Types

enum  { COUNT = 1024/SIZE }
 

Private Attributes

DynArray< Block *, 10 > blockPtrs
 
Chunkroot
 
int currentAllocs
 
int nAllocs
 
int maxAllocs
 

Detailed Description

template<int SIZE>
class tinyxml2::MemPoolT< SIZE >

Definition at line 259 of file tinyxml2.h.

Member Enumeration Documentation

template<int SIZE>
anonymous enum
private
Enumerator
COUNT 

Definition at line 309 of file tinyxml2.h.

309 { COUNT = 1024/SIZE };

Constructor & Destructor Documentation

template<int SIZE>
tinyxml2::MemPoolT< SIZE >::MemPoolT ( )
inline

Definition at line 262 of file tinyxml2.h.

262 : root(0), currentAllocs(0), nAllocs(0), maxAllocs(0) {}
template<int SIZE>
tinyxml2::MemPoolT< SIZE >::~MemPoolT ( )
inline

Definition at line 263 of file tinyxml2.h.

263  {
264  // Delete the blocks.
265  for( int i=0; i<blockPtrs.Size(); ++i ) {
266  delete blockPtrs[i];
267  }
268  }
DynArray< Block *, 10 > blockPtrs
Definition: tinyxml2.h:317

Member Function Documentation

template<int SIZE>
virtual void* tinyxml2::MemPoolT< SIZE >::Alloc ( )
inlinevirtual

Implements tinyxml2::MemPool.

Definition at line 273 of file tinyxml2.h.

273  {
274  if ( !root ) {
275  // Need a new block.
276  Block* block = new Block();
277  blockPtrs.Push( block );
278 
279  for( int i=0; i<COUNT-1; ++i ) {
280  block->chunk[i].next = &block->chunk[i+1];
281  }
282  block->chunk[COUNT-1].next = 0;
283  root = block->chunk;
284  }
285  void* result = root;
286  root = root->next;
287 
288  ++currentAllocs;
290  nAllocs++;
291  return result;
292  }
DynArray< Block *, 10 > blockPtrs
Definition: tinyxml2.h:317
template<int SIZE>
int tinyxml2::MemPoolT< SIZE >::CurrentAllocs ( ) const
inline

Definition at line 271 of file tinyxml2.h.

271 { return currentAllocs; }
template<int SIZE>
virtual void tinyxml2::MemPoolT< SIZE >::Free ( void *  mem)
inlinevirtual

Implements tinyxml2::MemPool.

Definition at line 293 of file tinyxml2.h.

293  {
294  if ( !mem ) return;
295  --currentAllocs;
296  Chunk* chunk = (Chunk*)mem;
297 #ifdef DEBUG
298  memset( chunk, 0xfe, sizeof(Chunk) );
299 #endif
300  chunk->next = root;
301  root = chunk;
302  }
template<int SIZE>
virtual int tinyxml2::MemPoolT< SIZE >::ItemSize ( ) const
inlinevirtual

Implements tinyxml2::MemPool.

Definition at line 270 of file tinyxml2.h.

270 { return SIZE; }
template<int SIZE>
void tinyxml2::MemPoolT< SIZE >::Trace ( const char *  name)
inline

Definition at line 303 of file tinyxml2.h.

303  {
304  printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
305  name, maxAllocs, maxAllocs*SIZE/1024, currentAllocs, SIZE, nAllocs, blockPtrs.Size() );
306  }
DynArray< Block *, 10 > blockPtrs
Definition: tinyxml2.h:317

Member Data Documentation

template<int SIZE>
DynArray< Block*, 10 > tinyxml2::MemPoolT< SIZE >::blockPtrs
private
template<int SIZE>
int tinyxml2::MemPoolT< SIZE >::currentAllocs
private
template<int SIZE>
int tinyxml2::MemPoolT< SIZE >::maxAllocs
private
template<int SIZE>
int tinyxml2::MemPoolT< SIZE >::nAllocs
private
template<int SIZE>
Chunk* tinyxml2::MemPoolT< SIZE >::root
private

The documentation for this class was generated from the following file:

Generated on Thu Jul 7 2016 11:09:52 for antioch-0.4.0 by  doxygen 1.8.8