Public Member Functions | |
FixedAllocator () | |
Create a FixedAllocator which manages blocks of 'blockSize' size. | |
~FixedAllocator () | |
Destroy the FixedAllocator and release all its Chunks. | |
void | Initialize (std::size_t blockSize, std::size_t pageSize) |
Initializes a FixedAllocator by calculating # of blocks per Chunk. | |
void * | Allocate (void) |
bool | Deallocate (void *p, Chunk *hint) |
std::size_t | BlockSize () const |
Returns block size with which the FixedAllocator was initialized. | |
bool | TrimEmptyChunk (void) |
bool | TrimChunkList (void) |
std::size_t | CountEmptyChunks (void) const |
bool | IsCorrupt (void) const |
const Chunk * | HasBlock (void *p) const |
|
Returns pointer to allocated memory block of fixed size - or NULL if it failed to allocate. |
|
Returns count of empty Chunks held by this allocator. Complexity is O(C) where C is the total number of Chunks - empty or used. |
|
Deallocate a memory block previously allocated with Allocate. If the block is not owned by this FixedAllocator, it returns false so that SmallObjAllocator can call the default deallocator. If the block was found, this returns true. |
|
Returns true if the block at address p is within a Chunk owned by this FixedAllocator. Complexity is O(C) where C is the total number of Chunks - empty or used. |
|
Determines if FixedAllocator is corrupt. Checks data members to see if any have erroneous values, or violate class invariants. It also checks if any Chunk is corrupt. Complexity is O(C) where C is the number of Chunks. If any data is corrupt, this will return true in release mode, or assert in debug mode. |
|
Releases unused spots from ChunkList. This takes constant time with respect to # of Chunks, but actual time depends on underlying memory allocator.
|
|
Releases the memory used by the empty Chunk. This will take constant time under any situation.
|