Defines | |
#define | _VAL(x) #x |
#define | _STR(x) _VAL(x) |
#define | STATIC_CAST(self, subClass, member) ((subClass*) (((char*) self) - (offsetof(subClass, member)))) |
#define | MALLOC(nbBytes, tag) (pmalloc(nbBytes, tag, L(__FILE__), __LINE__)) |
#define | CALLOC(nbElem, elemSize, tag) (pcalloc(nbElem, elemSize , tag, L(__FILE__), __LINE__)) |
#define | CALLOC_CLR(nbElem, elemSize, tag) (pcalloc(nbElem, elemSize , tag, L(__FILE__), __LINE__)) |
#define | REALLOC(ptr, newSize) (prealloc(ptr, newSize, L(__FILE__), __LINE__)) |
#define | NEW(type, tag) ((type*) MALLOC(sizeof(type), tag)) |
#define | NEW_ARRAY(type, nbElem, tag) ((type *) CALLOC(nbElem, sizeof(type), tag)) |
#define | FREE(ptr) pfree(ptr, L(__FILE__), __LINE__) |
Functions | |
PORTABLE_API ESR_ReturnCode | PMemInit (void) |
PORTABLE_API ESR_ReturnCode | PMemShutdown (void) |
PORTABLE_API ESR_ReturnCode | PMemSetLogFile (PFile *file) |
PORTABLE_API ESR_ReturnCode | PMemDumpLogFile (void) |
PORTABLE_API ESR_ReturnCode | PMemSetLogEnabled (ESR_BOOL value) |
PORTABLE_API ESR_ReturnCode | PMemLogFree (void *ptr) |
PORTABLE_API ESR_ReturnCode | PMemReport (PFile *file) |
PORTABLE_API ESR_ReturnCode | PMemorySetPoolSize (size_t size) |
PORTABLE_API ESR_ReturnCode | PMemoryGetPoolSize (size_t *size) |
#define _STR | ( | x | ) | _VAL(x) |
Converts a digit to a string.
#define _VAL | ( | x | ) | #x |
Returns macro to string format.
#define CALLOC | ( | nbElem, | |||
elemSize, | |||||
tag | ) | (pcalloc(nbElem, elemSize , tag, L(__FILE__), __LINE__)) |
Portable calloc()
#define FREE | ( | ptr | ) | pfree(ptr, L(__FILE__), __LINE__) |
Portable free()
#define MALLOC | ( | nbBytes, | |||
tag | ) | (pmalloc(nbBytes, tag, L(__FILE__), __LINE__)) |
Portable malloc()
#define NEW | ( | type, | |||
tag | ) | ((type*) MALLOC(sizeof(type), tag)) |
Portable new()
#define NEW_ARRAY | ( | type, | |||
nbElem, | |||||
tag | ) | ((type *) CALLOC(nbElem, sizeof(type), tag)) |
Allocates a new array
#define REALLOC | ( | ptr, | |||
newSize | ) | (prealloc(ptr, newSize, L(__FILE__), __LINE__)) |
Portable realloc()
#define STATIC_CAST | ( | self, | |||
subClass, | |||||
member | ) | ((subClass*) (((char*) self) - (offsetof(subClass, member)))) |
<static_cast> implementation for C.
PORTABLE_API ESR_ReturnCode PMemDumpLogFile | ( | void | ) |
Dumps memory report to the log file, closes it and disables logging.
PORTABLE_API ESR_ReturnCode PMemInit | ( | void | ) |
Initializes the memory management API.
PORTABLE_API ESR_ReturnCode PMemLogFree | ( | void * | ptr | ) |
Hide memory allocation from pmemReport() by pretending the memory was deallocating. This is used to hide memory leaks from pmemReport(), which is useful for internal variables which are deallocated after the final call to pmemReport() occurs.
ptr | Address of memory allocation that should be hidden |
PORTABLE_API ESR_ReturnCode PMemoryGetPoolSize | ( | size_t * | size | ) |
Get the memory pool size when S2G uses its own memory management
size | the memory pool size in byte |
PORTABLE_API ESR_ReturnCode PMemorySetPoolSize | ( | size_t | size | ) |
Allow user to set the memory pool size when S2G uses its own memory management. It should be called before PMemInit() The predefined (default) size is 3M for S2G
size | the memory pool size in byte |
PORTABLE_API ESR_ReturnCode PMemReport | ( | PFile * | file | ) |
Generates a report of the memory allocation.
file | A file in which the report is generated. If set to NULL, the report will be generated in the same file as that was provided to pmemInit. Therefore, it is possible that no report is generated if the function is invoked with NULL and pmemInit was also invoked with NULL. |
PORTABLE_API ESR_ReturnCode PMemSetLogEnabled | ( | ESR_BOOL | value | ) |
Enables/disables memory logging. This is useful for hiding allocations/deallocation from pmemReport() and other reporting mechanisms, simply disable logging prior to hidden operations and reenable it thereafter.
value | True if logging should be enabled |
PORTABLE_API ESR_ReturnCode PMemSetLogFile | ( | PFile * | file | ) |
Enables low-level logging to file. This logs individual memory allocations and deallocations. On shutdown, pmemDumpLogFile() will be invoked.
file | A file in which logging of memory related operations should be performed. If NULL, no logging is performed. |
PORTABLE_API ESR_ReturnCode PMemShutdown | ( | void | ) |
Shutdowns the memory management API. pmemReport is invoked with the same file that was provided to pmemInit.