Nebula
Loading...
Searching...
No Matches
Memory::PoolArrayAllocator Class Reference

#include <poolarrayallocator.h>

Detailed Description

Allocates small memory blocks from an array of fixed-size memory pools.

Bigger allocation go directly through to a heap. Note that when freeing a memory block, there are 2 options: one with providing the size of the memory block (which is probably a bit faster) and one conventional without providing the size.

Public Member Functions

 PoolArrayAllocator ()
 constructor
 
 ~PoolArrayAllocator ()
 destructor
 
void Setup (const char *name, Memory::HeapType heapType, uint poolSizes[NumPools])
 setup the pool allocator, name must be a static string!
 
void * Alloc (SizeT size)
 allocate a block of memory from the pool
 
void Free (void *ptr, SizeT size)
 free a block of memory from the pool array with original block size
 
void Free (void *ptr)
 free a block of memory from the pool array
 
const MemoryPoolGetMemoryPool (IndexT index) const
 access to memory pool at pool index (for debugging)
 

Static Public Attributes

static const SizeT NumPools = 8
 number of pools
 

Private Attributes

Memory::HeapType heapType
 
const char * name
 
MemoryPool memoryPools [NumPools]
 

Constructor & Destructor Documentation

◆ PoolArrayAllocator()

Memory::PoolArrayAllocator::PoolArrayAllocator ( )

constructor

◆ ~PoolArrayAllocator()

Memory::PoolArrayAllocator::~PoolArrayAllocator ( )

destructor

Member Function Documentation

◆ Alloc()

void * Memory::PoolArrayAllocator::Alloc ( SizeT size)

allocate a block of memory from the pool

◆ Free() [1/2]

void Memory::PoolArrayAllocator::Free ( void * ptr)

free a block of memory from the pool array

This is the slower version to free a memory block.

Worst case is, that the allocator needs to check each memory pool whether the pointer is owned by the pool.

◆ Free() [2/2]

void Memory::PoolArrayAllocator::Free ( void * ptr,
SizeT size )

free a block of memory from the pool array with original block size

This is the faster version to free a memory block, if the caller knows the size of the memory block we can compute the memory pool index whithout asking each pool whether the pointer is owned by this pool.

◆ GetMemoryPool()

const MemoryPool & Memory::PoolArrayAllocator::GetMemoryPool ( IndexT index) const

access to memory pool at pool index (for debugging)

◆ Setup()

void Memory::PoolArrayAllocator::Setup ( const char * name,
Memory::HeapType heapType,
uint poolSizes[NumPools] )

setup the pool allocator, name must be a static string!

Member Data Documentation

◆ heapType

Memory::HeapType Memory::PoolArrayAllocator::heapType
private

◆ memoryPools

MemoryPool Memory::PoolArrayAllocator::memoryPools[NumPools]
private

◆ name

const char* Memory::PoolArrayAllocator::name
private

◆ NumPools

const SizeT Memory::PoolArrayAllocator::NumPools = 8
static

number of pools


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