ug4
FixedAllocator Class Reference

#include <small_object_allocator.h>

Classes

struct  Chunk
 

Public Member Functions

void * allocate ()
 
void deallocate (void *p)
 
 FixedAllocator (std::size_t blockSize, unsigned char numBlocksPerChunk)
 

Private Types

typedef std::vector< ChunkChunks
 

Private Member Functions

bool pointer_is_in_chunk (void *p, Chunk *chunk)
 

Private Attributes

Chunkm_allocChunk
 
std::size_t m_blockSize
 
Chunks m_chunks
 
int m_deallocChunkIndex
 
int m_emptyChunkIndex
 
unsigned char m_numBlocksPerChunk
 
std::size_t m_numFreeBlocks
 

Detailed Description

Instances of this class can be used to allocate small objects of the same size in a highly efficient way.

Member Typedef Documentation

◆ Chunks

typedef std::vector<Chunk> FixedAllocator::Chunks
private

Constructor & Destructor Documentation

◆ FixedAllocator()

FixedAllocator::FixedAllocator ( std::size_t  blockSize,
unsigned char  numBlocksPerChunk 
)

Member Function Documentation

◆ allocate()

◆ deallocate()

◆ pointer_is_in_chunk()

bool FixedAllocator::pointer_is_in_chunk ( void *  p,
Chunk chunk 
)
inlineprivate

Member Data Documentation

◆ m_allocChunk

Chunk* FixedAllocator::m_allocChunk
private

Referenced by allocate().

◆ m_blockSize

std::size_t FixedAllocator::m_blockSize
private

◆ m_chunks

Chunks FixedAllocator::m_chunks
private

Referenced by allocate(), and deallocate().

◆ m_deallocChunkIndex

int FixedAllocator::m_deallocChunkIndex
private

Referenced by allocate(), and deallocate().

◆ m_emptyChunkIndex

int FixedAllocator::m_emptyChunkIndex
private

Referenced by deallocate().

◆ m_numBlocksPerChunk

unsigned char FixedAllocator::m_numBlocksPerChunk
private

◆ m_numFreeBlocks

std::size_t FixedAllocator::m_numFreeBlocks
private

Referenced by allocate(), and deallocate().


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