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::MemoryManagerHandle 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.
- 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.