The geRam module is a layer over memory management designed to provide an added measure of safety and debug build checking on allocations.
Use this module as you would normally use malloc, realloc and free. Allocations will be tracked in debug builds via support code bound to your applications through macros in ram.h. You can get reports on allocations, including leaks and possible memory corruption by calling geRam_ReportAllocations. This will give a dump via OutputDebugString of allocations that have not been freed, plus of allocated blocks that have been corrupted. The APIs have debug build checks in them to check block integrity on calls to geRam_Free, in an effort to catch problems before they become too far removed from their source.
void *geRam_Allocate(uint32 Size)
Description: Allocates memory.
Parameters:
| Size | Size, in bytes, of the block to allocate. |
Returns: Pointer to the new memory block on success, NULL on failure.
Description: Frees a block allocated with geRam_Allocate.
Parameters:
| Ptr | Block to free. |
Returns: void.
void *geRam_Realloc(void *Ptr, uint32 NewSize)
Description: Resizes a block of memory. This function is equivalent to realloc.
Parameters:
| Ptr |
Block to resize. |
| NewSize | New size of the block. |
Returns: Pointer to new block of memory on success, NULL on failure.
void geRam_ReportAllocations(void)
Description: Dumps a report on currently allocated blocks.
Parameters:
| void |
Returns: void.
Remarks: This function will do a dump via OutputDebugString of all the blocks that are currently allocated, listing the file name and line number of the source module from which the block was allocated. Blocks which have been corrupted in sentinel areas reserved by geRam_Allocate will be flagged as such, and reported as well. This function is only operational in debug builds.