ug4
FixedAllocator::Chunk Struct Reference

Public Member Functions

void * allocate (std::size_t blockSize)
 returns 0 if no more blocks are available. More...
 
void deallocate (void *p, std::size_t blockSize)
 deallocates the given pointer. More...
 
void free ()
 call this method instead of a destructor More...
 
void init (std::size_t blockSize, unsigned char numBlocks)
 be careful. numBlocks has to be <= 255. More...
 

Public Attributes

unsigned char m_firstAvailableBlock
 
unsigned char m_numAvailableBlocks
 
unsigned char * m_pData
 

Detailed Description

The Chunk structure has to be used with great care. A represents is a block of memory, in which it allocates small objects. Be sure that the blockSize used in the calls is the same for all calls to an instance.

Member Function Documentation

◆ allocate()

void * FixedAllocator::Chunk::allocate ( std::size_t  blockSize)

returns 0 if no more blocks are available.

Referenced by FixedAllocator::allocate().

◆ deallocate()

void FixedAllocator::Chunk::deallocate ( void *  p,
std::size_t  blockSize 
)

deallocates the given pointer.

Make sure that p was allocated by the same instance on which you call deallocate.

References p.

Referenced by FixedAllocator::deallocate().

◆ free()

void FixedAllocator::Chunk::free ( )

call this method instead of a destructor

◆ init()

void FixedAllocator::Chunk::init ( std::size_t  blockSize,
unsigned char  numBlocks 
)

be careful. numBlocks has to be <= 255.

References m_firstAvailableBlock, m_numAvailableBlocks, m_pData, and p.

Referenced by FixedAllocator::allocate().

Member Data Documentation

◆ m_firstAvailableBlock

unsigned char FixedAllocator::Chunk::m_firstAvailableBlock

Referenced by init().

◆ m_numAvailableBlocks

unsigned char FixedAllocator::Chunk::m_numAvailableBlocks

◆ m_pData

unsigned char* FixedAllocator::Chunk::m_pData

The documentation for this struct was generated from the following files: