#include <kmemory.h>
Classes |
|
struct | KBlockHeader |
Public Member Functions |
|
KMemoryReusePool (size_t pSizeRange=1024 *128, int pStrideShift=2, int pAlignmentShift=0, size_t pTotalAllocatedMax=0) | |
virtual | ~KMemoryReusePool () |
virtual void | Purge () |
virtual void * | Malloc (size_t pSize) |
virtual void * | Calloc (size_t pCount, size_t pSize) |
virtual void * | Realloc (void *pData, size_t pSize) |
virtual void | Free (void *pData) |
Protected Member Functions |
|
bool | SizeFitsInPool (size_t pSize) const |
bool | PoolIsFull () const |
kUChar | ComputeAlignmentOffset (void *pBuffer) |
void * | AssignHeaderAndReturnBlock (void *pBuffer, size_t pBufferSize) |
size_t | GetBufferAndSize (void *pBlock, void *&pBuffer) |
Static Protected Member Functions |
|
static int | ComputeRightShiftRemainder (int pStrideShift) |
static size_t | GetHeaderSize () |
Protected Attributes |
|
KMpMutex * | mLock |
Critical section on our pool (maintained by
pointer only to not force a dependency on windows.h at large).
|
|
void * | mBuffer |
Our array of free lists, of size
mBufferSize. |
|
size_t const | mSizeRange |
Maximum alloc size. |
|
size_t const | mBufferSize |
mSizeRange >> mStrideShift. |
|
int const | mStrideShift |
Divider for mSizeRange. |
|
int const | mStrideRemainder |
A mask of the remainder of a right shift
done with mStrideShift. |
|
int const | mAlignmentShift |
Multiplier, to specify an alignment in
bytes. |
|
size_t const | mTotalAllocatedMax |
Maximum total amount of memory handed out or
managed by this pool (past this point, normal allocs are done).
|
|
size_t | mTotalAllocated |
The total amount of memory handed out or
managed by this pool. |
|
size_t | mTotalBlocks |
The total number of blocks handed out or
managed by this pool. |
KMemoryReusePool | ( | size_t | pSizeRange =
1024 *128 , |
int | pStrideShift = 2 , |
||
int | pAlignmentShift =
0 , |
||
size_t | pTotalAllocatedMax =
0 |
||
) | [explicit] |
virtual ~KMemoryReusePool | ( | ) | [virtual] |
virtual void Purge | ( | ) | [virtual] |
Reimplemented from KMemoryAllocator.
virtual void* Malloc | ( | size_t | pSize | ) | [virtual] |
Reimplemented from KMemoryAllocator.
virtual void* Calloc | ( | size_t | pCount, |
size_t | pSize | ||
) | [virtual] |
Reimplemented from KMemoryAllocator.
virtual void* Realloc | ( | void * | pData, |
size_t | pSize | ||
) | [virtual] |
Reimplemented from KMemoryAllocator.
virtual void Free | ( | void * | pData | ) | [virtual] |
Reimplemented from KMemoryAllocator.
bool SizeFitsInPool | ( | size_t | pSize | ) | const [inline, protected] |
Definition at line 181 of file kmemory.h.
{ return (pSize >= GetHeaderSize() && pSize < mSizeRange); }
bool PoolIsFull | ( | ) | const [inline, protected] |
Definition at line 182 of file kmemory.h.
{ return (0 != mTotalAllocatedMax && mTotalAllocated > mTotalAllocatedMax); }
kUChar ComputeAlignmentOffset | ( | void * | pBuffer | ) | [protected] |
static int ComputeRightShiftRemainder | ( | int | pStrideShift | ) | [static, protected] |
void* AssignHeaderAndReturnBlock | ( | void * | pBuffer, |
size_t | pBufferSize | ||
) | [protected] |
size_t GetBufferAndSize | ( | void * | pBlock, |
void *& | pBuffer | ||
) | [protected] |
static size_t GetHeaderSize | ( | ) | [static, protected] |
KMpMutex* mLock
[protected] |
Critical section on our pool (maintained by pointer only to not force a dependency on windows.h at large).
void* mBuffer
[protected] |
Our array of free lists, of size mBufferSize.
size_t const mSizeRange
[protected] |
size_t const mBufferSize
[protected] |
int const mStrideShift
[protected] |
int const mStrideRemainder
[protected] |
A mask of the remainder of a right shift done with mStrideShift.
int const mAlignmentShift
[protected] |
Multiplier, to specify an alignment in bytes.
size_t const mTotalAllocatedMax
[protected] |
Maximum total amount of memory handed out or managed by this pool (past this point, normal allocs are done).
size_t mTotalAllocated
[protected] |
The total amount of memory handed out or managed by this pool.
size_t mTotalBlocks
[protected] |
The total number of blocks handed out or managed by this pool.