Base class for memory managers. More...
Public Types | |
typedef void *(*) | ProcAlloc(MemoryManager *pThis, uintptr_t uSize) |
Function prototype for allocating memory. | |
typedef void(*) | ProcFree(MemoryManager *pThis, const void *pInput) |
Function prototype for releasing memory. | |
typedef void *(*) | ProcRealloc(MemoryManager *pThis, const void *pInput, uintptr_t uSize) |
Function prototype for reallocating memory. | |
typedef void(*) | ProcShutdown(MemoryManager *pThis) |
Function prototype for destructor. | |
Public Member Functions | |
void * | alloc (uintptr_t uSize) noexcept |
Allocate memory. | |
void | free (const void *pInput) noexcept |
Release memory. | |
void * | realloc (const void *pInput, uintptr_t uSize) noexcept |
Reallocate memory. | |
void | shutdown (void) noexcept |
Shut down the memory manager. | |
void * | alloc_clear (uintptr_t uSize) noexcept |
Allocate a block of pre-zeroed memory. | |
Static Public Member Functions | |
static void | shutdown (MemoryManager *pThis) noexcept |
Default memory manager destructor. | |
Public Attributes | |
ProcAlloc | m_pAlloc |
Pointer to allocation function. | |
ProcFree | m_pFree |
Pointer to memory release function. | |
ProcRealloc | m_pRealloc |
Pointer to the memory reallocation function. | |
ProcShutdown | m_pShutdown |
Pointer to the shutdown function. | |
Base class for memory managers.
To avoid the use of virtual pointers and to gain ANSI C compatibility, the "base class" has all the virtual functions defined explicitly, and calls to the base class are passed through the function pointers while calls to the derived classed (When known) are performed by direct calls.
Since this is defined as a base class, it's not meant to be used directly. You should derive from this class and either implement your own memory handler, or use the predefined MemoryManagerANSI or MemoryManagerHandle classes.
void *( *) Burger::MemoryManager::ProcAlloc(MemoryManager *pThis, uintptr_t uSize) |
Function prototype for allocating memory.
void( *) Burger::MemoryManager::ProcFree(MemoryManager *pThis, const void *pInput) |
Function prototype for releasing memory.
void *( *) Burger::MemoryManager::ProcRealloc(MemoryManager *pThis, const void *pInput, uintptr_t uSize) |
Function prototype for reallocating memory.
void( *) Burger::MemoryManager::ProcShutdown(MemoryManager *pThis) |
Function prototype for destructor.
|
inlinenoexcept |
Allocate memory.
Call the "virtual" function in m_pAlloc to allocate memory
uSize | Number of bytes to allocate |
|
noexcept |
Allocate a block of pre-zeroed memory.
Allocate a block of memory and return either nullptr in the case of an out of memory condition or if the amount requested was zero, otherwise return a valid pointer of memory that has been preset to zero.
uSize | Number of bytes to allocate. |
|
inlinenoexcept |
Release memory.
Call the "virtual" function in m_pFree to allocate memory
pInput | Pointer to memory to release |
|
inlinenoexcept |
Reallocate memory.
Call the "virtual" function in m_pRealloc to reallocate memory
pInput | Pointer to memory to read from and release |
uSize | Number of bytes to allocate |
|
staticnoexcept |
Default memory manager destructor.
This function does nothing. It's intended to be a placeholder for derived memory managers that do not have shutdown functions (Such as those that have the OS or ANSI malloc/free to perform these operations)
pThis | The "this" pointer |
|
inlinenoexcept |
Shut down the memory manager.
Call the "virtual" function in m_pShutdown to shut down the memory system
ProcAlloc Burger::MemoryManager::m_pAlloc |
Pointer to allocation function.
ProcFree Burger::MemoryManager::m_pFree |
Pointer to memory release function.
ProcRealloc Burger::MemoryManager::m_pRealloc |
Pointer to the memory reallocation function.
ProcShutdown Burger::MemoryManager::m_pShutdown |
Pointer to the shutdown function.