Nebula
|
#include <win32memorypool.h>
A simple thread-safe memory pool.
Memory pool items are 16-byte aligned.
FIXME:
Public Member Functions | |
Win32MemoryPool () | |
constructor | |
~Win32MemoryPool () | |
destructor | |
void | Setup (Memory::HeapType heapType, uint blockSize, uint numBlocks) |
setup the memory pool | |
void * | Alloc () |
allocate a block from the pool (NOTE: returns 0 if pool exhausted!) | |
void | Free (void *ptr) |
deallocate a block from the pool | |
bool | IsPoolBlock (void *ptr) const |
return true if block is owned by this pool | |
uint | GetNumBlocks () const |
get number of allocated blocks in pool | |
uint | GetBlockSize () const |
get block size | |
uint | GetAlignedBlockSize () const |
get aligned block size | |
uint | GetPoolSize () const |
get pool size | |
Static Public Member Functions | |
static uint | ComputeAlignedBlockSize (uint blockSize) |
compute the actual block size including alignment and management data | |
Private Attributes | |
Memory::HeapType | heapType |
uint | blockSize |
uint | alignedBlockSize |
uint | poolSize |
uint | numBlocks |
SLIST_HEADER | listHead |
ubyte * | poolStart |
ubyte * | poolEnd |
Static Private Attributes | |
static const uint | FreeBlockPattern = 0xFE |
get current allocation count | |
static const uint | NewBlockPattern = 0xFD |
static const int | BlockAlign = 16 |
Win32::Win32MemoryPool::Win32MemoryPool | ( | ) |
constructor
Win32::Win32MemoryPool::~Win32MemoryPool | ( | ) |
destructor
void * Win32::Win32MemoryPool::Alloc | ( | ) |
allocate a block from the pool (NOTE: returns 0 if pool exhausted!)
compute the actual block size including alignment and management data
void Win32::Win32MemoryPool::Free | ( | void * | ptr | ) |
deallocate a block from the pool
|
inline |
get aligned block size
|
inline |
get block size
|
inline |
get number of allocated blocks in pool
|
inline |
get pool size
|
inline |
return true if block is owned by this pool
void Win32::Win32MemoryPool::Setup | ( | Memory::HeapType | heapType, |
uint | blockSize, | ||
uint | numBlocks ) |
setup the memory pool
NOTE: name must be a static string!
|
private |
|
staticprivate |
|
private |
|
staticprivate |
get current allocation count
|
private |
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |