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.(C) 2009 Radon Labs GmbH
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 MemoryPool & | GetMemoryPool (IndexT index) const |
access to memory pool at pool index (for debugging) | |
Static Public Attributes | |
static const SizeT | NumPools = 8 |
number of pools |
Member Function Documentation
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.
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.