PMemory API functions


Detailed Description

Library for basic memory management. Call PMemInit() to initialize and PmemShutdown() to shutdown module.


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 Documentation

#define _STR (  )     _VAL(x)

Converts a digit to a string.

#define _VAL (  )     #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.


Function Documentation

PORTABLE_API ESR_ReturnCode PMemDumpLogFile ( void   ) 

Dumps memory report to the log file, closes it and disables logging.

Returns:
ESR_INVALID_STATE if the PMem module is not initialized or an internal error occurs

PORTABLE_API ESR_ReturnCode PMemInit ( void   ) 

Initializes the memory management API.

Returns:
ESR_INVALID_STATE if the PMem module is already initialized or an internal error occurs

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.

Parameters:
ptr Address of memory allocation that should be hidden
Returns:
ESR_SUCCESS

PORTABLE_API ESR_ReturnCode PMemoryGetPoolSize ( size_t *  size  ) 

Get the memory pool size when S2G uses its own memory management

Parameters:
size the memory pool size in byte
Returns:
ESR_NOT_SUPPORTED if S2G uses native memory management

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

Parameters:
size the memory pool size in byte
Returns:
ESR_NOT_SUPPORTED if S2G uses native memory management; ESR_INVALID_STATE if it is called after PMemInit()

PORTABLE_API ESR_ReturnCode PMemReport ( PFile file  ) 

Generates a report of the memory allocation.

Parameters:
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.
Returns:
ESR_WRITE_ERROR if an error occurs while writing to the file

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.

Parameters:
value True if logging should be enabled
Returns:
ESR_SUCCESS

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.

Parameters:
file A file in which logging of memory related operations should be performed. If NULL, no logging is performed.
Returns:
ESR_INVALID_STATE if the PMem module is not initialized

PORTABLE_API ESR_ReturnCode PMemShutdown ( void   ) 

Shutdowns the memory management API. pmemReport is invoked with the same file that was provided to pmemInit.

Returns:
ESR_INVALID_STATE if the PMem module is not initialized


Generated on Thu May 1 15:37:26 2008 for SREC by  doxygen 1.5.3