Singleton class for global memory allocation. More...
#include <brglobalmemorymanager.h>


Public Member Functions | |
| BURGER_INLINE MemoryManager * | GetInstance (void) const |
| Return the instance of the active global memory manager. | |
Static Public Member Functions | |
| static void BURGER_API | Init (MemoryManager *pInstance) |
| Initialize the global memory allocator. | |
| static void BURGER_API | Shutdown (void) |
| Shut down the global memory allocator. | |
| static void *BURGER_API | Alloc (WordPtr uSize) |
| Allocate memory. | |
| static void BURGER_API | Free (const void *pInput) |
| Release memory. | |
| static void *BURGER_API | Realloc (const void *pInput, WordPtr uSize) |
| Reallocate previously allocated memory. | |
| static void *BURGER_API | AllocClear (WordPtr uSize) |
| Allocate a block of pre-zeroed memory. | |
Private Attributes | |
| MemoryManager * | m_pInstance |
| Pointer to the original derived class. | |
Static Private Attributes | |
| static GlobalMemoryManager | g_MemoryManager |
| Global singleton data for the GlobalMemoryManager class. | |
Singleton class for global memory allocation.
To implement a workable copy of malloc(), free() etc., a method was needed to contain the instance pointer of the burgerlib memory manager and retain the ability to change the implementation at will. This was needed since Burgerlib Memory Managers are all class based so a "this" pointer is needed in all calls whereas the ANSI calling convention assumes a global implementation.
By using this class, which is initialized either with Burger::MemoryManagerANSI or Burger::MemoryManagerFast all functions that allocate memory from the global pool can and will be redirected.
Mostly used to make search and replace of malloc and new trivial. Use of this class is not encouraged. It's only for quick porting of legacy code that isn't multi-thread friendly.
| void *BURGER_API Burger::GlobalMemoryManager::Alloc | ( | WordPtr | uSize | ) | [static] |
Allocate memory.
Using the redirection values, allocate the memory requested.
| uSize | Number of bytes requested to allocate |
Reimplemented from Burger::MemoryManager.
| static void* BURGER_API Burger::GlobalMemoryManager::AllocClear | ( | WordPtr | uSize | ) | [static] |
Allocate a block of pre-zeroed memory.
Allocate a block of memory and return either NULL 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. |
Reimplemented from Burger::MemoryManager.
| void BURGER_API Burger::GlobalMemoryManager::Free | ( | const void * | pInput | ) | [static] |
Release memory.
Using the redirection values, release the memory. NULL performs no operation.
| pInput | Pointer to memory to release. |
Reimplemented from Burger::MemoryManager.
| MemoryManager * Burger::GlobalMemoryManager::GetInstance | ( | void | ) | const [inline] |
Return the instance of the active global memory manager.
| void BURGER_API Burger::GlobalMemoryManager::Init | ( | MemoryManager * | pInstance | ) | [static] |
Initialize the global memory allocator.
This function copies the pointer to the MemoryManager class and will use this instance for all memory operations.
| pInstance | Pointer to an initialized MemoryManager. |
| void *BURGER_API Burger::GlobalMemoryManager::Realloc | ( | const void * | pInput, | |
| WordPtr | uSize | |||
| ) | [static] |
Reallocate previously allocated memory.
Using the redirection values, reallocate the memory.
| pInput | Pointer to memory to reallocate. NULL assumes no memory to copy from. | |
| uSize | New size of the buffer. |
Reimplemented from Burger::MemoryManager.
| void BURGER_API Burger::GlobalMemoryManager::Shutdown | ( | void | ) | [static] |
Shut down the global memory allocator.
Shut down the memory allocator through the m_pShutdown pointer.
Reimplemented from Burger::MemoryManager.
Burger::GlobalMemoryManager Burger::GlobalMemoryManager::g_MemoryManager [static, private] |
Global singleton data for the GlobalMemoryManager class.
Pointer to the original derived class.
1.7.1