ICoreAllocator class
ICoreAllocator is the base level abstract interface for allocating and deallocating memory.
Derived classes
- class FixedPoolAllocator
Public types
- enum class AllocFlags { MEM_TEMP = 0, MEM_PERM = 1 }
Public static functions
- static auto GetDefaultAllocator() -> ICoreAllocator*
Constructors, destructors, conversion operators
- ~ICoreAllocator() virtual
Public functions
Enum documentation
enum class ICoreAllocator:: AllocFlags
Enumerators | |
---|---|
MEM_TEMP |
hint to the heap implementation that this block will be freed shortly after it was allocated. To reduce heap fragmentation, these blocks are usually allocated at the opposite end of the heap from where permanent allocations are made. |
MEM_PERM |
Normal block of memory which will need to be retained for a long time. |
Function documentation
void* ICoreAllocator:: Alloc(size_ t size,
const char* name,
unsigned int flags) pure virtual
Parameters | |
---|---|
size | size of the requested block. |
name | name of the block (normally used for debugging purposes) |
flags | additional information on how to allocate the block (MEM_PERM or MEM_TEMP) |
Returns | A pointer to the allocated block if successful. NULL if the block could not be allocated. |
void* ICoreAllocator:: Alloc(size_ t size,
const char* name,
unsigned int flags,
unsigned int align,
unsigned int alignOffset = 0) pure virtual
Parameters | |
---|---|
size | size of the requested block. |
name | name of the block (normally used for debugging purposes) |
flags | additional information on how to allocate the block (MEM_PERM or MEM_TEMP) |
align | some power-of-2 boundary the block must be allocated on. address returned is guaranteed to be aligned to the requested boundary. |
alignOffset | a "header" amount which is subtracted from the power-of-2 alignment. A location inside a memory block will be aligned to this boundary. |
Returns | A pointer to the allocated block if successful. NULL if the block could not be allocated. |
void ICoreAllocator:: Free(void* block,
size_ t size = 0) pure virtual
Parameters | |
---|---|
block | pointer to the block to be freed. |
size | optional. It may be used to find the pool that the block belongs to. The implementation is free to ignore this and the caller cannot assume that the implementation will do anything with it. |