Singleton class for global memory allocation.
To implement a global, redirectable version of malloc(), free(), or realloc() for Burgerlib, a method was needed to contain the instance pointer of a memory manager for the global use of Burger 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 MemoryManagerANSI or MemoryManagerHandle all functions that allocate memory from the global pool can and will be redirected.
- Note
- This class is assumed to have functions that are thread safe. Any custom implementations on target platforms that support multi-threading must all be multi-core thread safe.
-
Since this a reference to the controlled class, NEVER manually up cast the global instance of this class. Use the get_instance(void) function to get the pointer to the real class if up casting is desired for system specific functionality is desired.