ReactOS  0.4.12-dev-51-ge94618b
tinyxml2::MemPoolT< SIZE > Class Template Reference

#include <tinyxml2.h>

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

Classes

struct  Block
 
union  Chunk
 

Public Types

enum  { COUNT = (4*1024)/SIZE }
 

Public Member Functions

 MemPoolT ()
 
 ~MemPoolT ()
 
void Clear ()
 
virtual int ItemSize () const
 
int CurrentAllocs () const
 
virtual voidAlloc ()
 
virtual void Free (void *mem)
 
void Trace (const char *name)
 
void SetTracked ()
 
int Untracked () const
 
- Public Member Functions inherited from tinyxml2::MemPool
 MemPool ()
 
virtual ~MemPool ()
 

Private Member Functions

 MemPoolT (const MemPoolT &)
 
void operator= (const MemPoolT &)
 

Private Attributes

DynArray< Block *, 10 > _blockPtrs
 
Chunk_root
 
int _currentAllocs
 
int _nAllocs
 
int _maxAllocs
 
int _nUntracked
 

Detailed Description

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

Definition at line 315 of file tinyxml2.h.

Member Enumeration Documentation

◆ anonymous enum

template<int SIZE>
anonymous enum
Enumerator
COUNT 

Definition at line 401 of file tinyxml2.h.

401 { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private

Constructor & Destructor Documentation

◆ MemPoolT() [1/2]

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

Definition at line 318 of file tinyxml2.h.

◆ ~MemPoolT()

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

Definition at line 319 of file tinyxml2.h.

319  {
320  Clear();
321  }

◆ MemPoolT() [2/2]

template<int SIZE>
tinyxml2::MemPoolT< SIZE >::MemPoolT ( const MemPoolT< SIZE > &  )
private

Member Function Documentation

◆ Alloc()

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

Implements tinyxml2::MemPool.

Definition at line 343 of file tinyxml2.h.

343  {
344  if ( !_root ) {
345  // Need a new block.
346  Block* block = new Block();
347  _blockPtrs.Push( block );
348 
349  for( int i=0; i<COUNT-1; ++i ) {
350  block->chunk[i].next = &block->chunk[i+1];
351  }
352  block->chunk[COUNT-1].next = 0;
353  _root = block->chunk;
354  }
355  void* result = _root;
356  _root = _root->next;
357 
358  ++_currentAllocs;
359  if ( _currentAllocs > _maxAllocs ) {
361  }
362  _nAllocs++;
363  _nUntracked++;
364  return result;
365  }
static unsigned int block
Definition: xmlmemory.c:118
DynArray< Block *, 10 > _blockPtrs
Definition: tinyxml2.h:414
GLenum GLclampf GLint i
Definition: glfuncs.h:14
GLuint64EXT * result
Definition: glext.h:11304

◆ Clear()

template<int SIZE>
void tinyxml2::MemPoolT< SIZE >::Clear ( )
inlinevirtual

Implements tinyxml2::MemPool.

Definition at line 323 of file tinyxml2.h.

323  {
324  // Delete the blocks.
325  while( !_blockPtrs.Empty()) {
326  Block* b = _blockPtrs.Pop();
327  delete b;
328  }
329  _root = 0;
330  _currentAllocs = 0;
331  _nAllocs = 0;
332  _maxAllocs = 0;
333  _nUntracked = 0;
334  }
DynArray< Block *, 10 > _blockPtrs
Definition: tinyxml2.h:414
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

◆ CurrentAllocs()

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

Definition at line 339 of file tinyxml2.h.

339  {
340  return _currentAllocs;
341  }

◆ Free()

template<int SIZE>
virtual void tinyxml2::MemPoolT< SIZE >::Free ( void mem)
inlinevirtual

Implements tinyxml2::MemPool.

Definition at line 367 of file tinyxml2.h.

367  {
368  if ( !mem ) {
369  return;
370  }
371  --_currentAllocs;
372  Chunk* chunk = static_cast<Chunk*>( mem );
373 #ifdef DEBUG
374  memset( chunk, 0xfe, sizeof(Chunk) );
375 #endif
376  chunk->next = _root;
377  _root = chunk;
378  }
#define memset(x, y, z)
Definition: compat.h:39

◆ ItemSize()

template<int SIZE>
virtual int tinyxml2::MemPoolT< SIZE >::ItemSize ( ) const
inlinevirtual

Implements tinyxml2::MemPool.

Definition at line 336 of file tinyxml2.h.

336  {
337  return SIZE;
338  }
#define SIZE
Definition: t_vb_render.c:51

◆ operator=()

template<int SIZE>
void tinyxml2::MemPoolT< SIZE >::operator= ( const MemPoolT< SIZE > &  )
private

◆ SetTracked()

template<int SIZE>
void tinyxml2::MemPoolT< SIZE >::SetTracked ( )
inlinevirtual

Implements tinyxml2::MemPool.

Definition at line 384 of file tinyxml2.h.

384  {
385  _nUntracked--;
386  }

◆ Trace()

template<int SIZE>
void tinyxml2::MemPoolT< SIZE >::Trace ( const char name)
inline

Definition at line 379 of file tinyxml2.h.

379  {
380  printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
382  }
DynArray< Block *, 10 > _blockPtrs
Definition: tinyxml2.h:414
Definition: name.c:36
#define printf
Definition: config.h:203

◆ Untracked()

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

Definition at line 388 of file tinyxml2.h.

388  {
389  return _nUntracked;
390  }

Member Data Documentation

◆ _blockPtrs

template<int SIZE>
DynArray< Block*, 10 > tinyxml2::MemPoolT< SIZE >::_blockPtrs
private

Definition at line 414 of file tinyxml2.h.

◆ _currentAllocs

template<int SIZE>
int tinyxml2::MemPoolT< SIZE >::_currentAllocs
private

Definition at line 417 of file tinyxml2.h.

◆ _maxAllocs

template<int SIZE>
int tinyxml2::MemPoolT< SIZE >::_maxAllocs
private

Definition at line 419 of file tinyxml2.h.

◆ _nAllocs

template<int SIZE>
int tinyxml2::MemPoolT< SIZE >::_nAllocs
private

Definition at line 418 of file tinyxml2.h.

◆ _nUntracked

template<int SIZE>
int tinyxml2::MemPoolT< SIZE >::_nUntracked
private

Definition at line 420 of file tinyxml2.h.

◆ _root

template<int SIZE>
Chunk* tinyxml2::MemPoolT< SIZE >::_root
private

Definition at line 415 of file tinyxml2.h.


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