![]() |
WE310F5
39.00.000
|
This section describes the M2MB API for the heap stat module. More...
Data Structures | |
struct | M2MB_ALLOC_NODE_DATA |
Structure for node data. More... | |
typedef struct M2MB_ALLOC_NODE_DATA | M2MB_HEAP_ALLOC_NODE_DATA_T |
Structure for node data. More... | |
void * | m2mb_heap_malloc (UINT32 reqBytes, char *file, int line) |
m2mb_heap_malloc allocates the memory for requested bytes(size) along with 20 bytes for M2MB_HEAP_ALLOC_NODE_T. More... | |
void * | m2mb_heap_realloc (void *ptr, UINT32 reqBytes, char *file, int line) |
m2mb_heap_realloc is called to reallocate the memory of size reqBytes pointed by pointer ptr. More... | |
void | m2mb_heap_free (void *ptr, char *file, int line) |
m2mb_heap_free is called to frees the memory pointed by ptr. More... | |
VOID | m2mb_heap_log_init (VOID) |
m2mb_heap_log_init is called to initialize the heap allocation list. More... | |
M2MB_HEAP_ALLOC_NODE_DATA_T * | m2mb_heap_getList (VOID) |
m2mb_heap_getList is called to get the pointer to the current node in the M2MB_HEAP_LOG_LIST_T. More... | |
VOID | m2mb_heap_resetTrace (VOID) |
m2mb_heap_resetTrace resets the current node in the list as the trace node. More... | |
UINT32 | m2mb_heap_getSize (UINT8 *ptr) |
m2mb_heap_getSize returns the size of current node data in bytes. More... | |
INT32 | m2mb_heap_stat (UINT32 *total_bytes, UINT32 *free_bytes) |
m2mb_heap_stat is called to get the status. More... | |
This section describes the M2MB API for the heap stat module.
Heap stat module provides API to get the current statistics of heap. It gives the total size of heap and available bytes in the heap. User may not be able to allocate memory even the size the user wants to allocate is lesser than the size available. This is because of fragmentation in the heap area.
typedef struct M2MB_ALLOC_NODE_DATA M2MB_HEAP_ALLOC_NODE_DATA_T |
Structure for node data.
Allocation node data, the node carries the information of the memory block allocated.
void m2mb_heap_free | ( | void * | ptr, |
char * | file, | ||
int | line | ||
) |
m2mb_heap_free is called to frees the memory pointed by ptr.
m2mb_heap_free is called to frees the memory pointed by ptr along with deleting the node carrying memory log details.
[in] | ptr | Pointer to memory block to be freed. |
[in] | file | Name of the file where m2mb_heap_free is called. |
[in] | line | Line number where m2mb_heap_free is called. |
M2MB_HEAP_ALLOC_NODE_DATA_T* m2mb_heap_getList | ( | VOID | ) |
m2mb_heap_getList is called to get the pointer to the current node in the M2MB_HEAP_LOG_LIST_T.
m2mb_heap_getList returns pointer to the current node list, M2MB_HEAP_LOG_LIST_T.
m2mb_heap_getSize returns the size of current node data in bytes.
m2mb_heap_getSize returns the size of current node data in bytes.
[in] | ptr | Pointer to the memory block. |
m2mb_heap_log_init is called to initialize the heap allocation list.
m2mb_heap_log_init initializes the list M2MB_HEAP_LOG_LIST_T used to log every memory allocation.
Example
void* m2mb_heap_malloc | ( | UINT32 | reqBytes, |
char * | file, | ||
int | line | ||
) |
m2mb_heap_malloc allocates the memory for requested bytes(size) along with 20 bytes for M2MB_HEAP_ALLOC_NODE_T.
m2mb_heap_malloc allocates the memory of 'size+20' bytes.
[in] | reqBytes | Size of the memory block. |
[in] | file | Name of the file where m2mb_heap_free is called. |
[in] | line | Line number where m2mb_heap_free is called. |
void* m2mb_heap_realloc | ( | void * | ptr, |
UINT32 | reqBytes, | ||
char * | file, | ||
int | line | ||
) |
m2mb_heap_realloc is called to reallocate the memory of size reqBytes pointed by pointer ptr.
m2mb_heap_realloc is called to reallocate the memory of size reqBytes pointed by pointer ptr.
[in] | ptr | Pointer to memory block to be reallocated. |
[in] | reqBytes | Size of the memory block to be reallocated. |
[in] | file | Name of the file where m2mb_heap_free is called. |
[in] | line | Line number where m2mb_heap_free is called. |
m2mb_heap_resetTrace resets the current node in the list as the trace node.
m2mb_heap_resetTrace resets the current node in the list as the trace node.
m2mb_heap_stat is called to get the status.
m2mb_heap_stat gets the memory heap status: Total bytes and Free bytes.
[out] | total_bytes | Pointer to a UINT32 to hold the total amount of heap bytes |
[out] | free_bytes | Pointer to a UINT32 to hold the approximated amount of free heap bytes |