WE310F5  39.00.000
m2mb_heap.h
Go to the documentation of this file.
1 /*===============================================================================================*/
2 /* >>> Copyright (C) Telit Communications S.p.A. Italy All Rights Reserved. <<< */
23 #ifndef M2MB_HEAP_API_H
24 #define M2MB_HEAP_API_H
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 
30 //#define M2MB_HEAP_DEBUG
31 #ifdef M2MB_HEAP_DEBUG
32 #define MALLOC(len) m2mb_heap_malloc(len, __FILE__, __LINE__)
33 #define CALLOC(nitems, size) m2mb_heap_calloc( nitems, size, __FILE__, __LINE__)
34 #define REALLOC(ptr,len) m2mb_heap_realloc(ptr, len, __FILE__, __LINE__)
35 #define FREE(ptr) m2mb_heap_free(ptr, __FILE__, __LINE__)
36 #else
37 #define MALLOC(len) m2mb_os_malloc(len)
38 #define CALLOC(nitems, size) m2mb_os_calloc( nitems, size)
39 #define FREE(ptr) m2mb_os_free(ptr)
40 #define REALLOC(ptr,len) m2mb_os_realloc(ptr,len)
41 #endif
42 
55 /*-----------------------------------------------------------------------------------------------*/
56 
61 /*-----------------------------------------------------------------------------------------------*/
62 #include <stdlib.h>
63 
64 /* Global defines ==============================================================================*/
65 
66 /* Global typedefs ==========================================================================*/
74 typedef struct M2MB_ALLOC_NODE_DATA
75 {
83 
84 
85 /* Global functions =========================================================*/
86 /*---------------------------------------------------------------------------*/
118 /*---------------------------------------------------------------------------*/
119 void *m2mb_heap_malloc(UINT32 reqBytes, char *file, int line);
120 
121 /*---------------------------------------------------------------------------*/
158 /*---------------------------------------------------------------------------*/
159 void *m2mb_heap_realloc(void *ptr, UINT32 reqBytes, char *file, int line);
160 
161 /*---------------------------------------------------------------------------*/
195 /*---------------------------------------------------------------------------*/
196 void m2mb_heap_free(void *ptr, char *file, int line);
197 
198 /*---------------------------------------------------------------------------*/
225 /*---------------------------------------------------------------------------*/
227 
228 /*---------------------------------------------------------------------------*/
259 /*---------------------------------------------------------------------------*/
261 
262 /*---------------------------------------------------------------------------*/
290 /*---------------------------------------------------------------------------*/
292 
293 /*---------------------------------------------------------------------------*/
327 /*---------------------------------------------------------------------------*/
329 
330 /*---------------------------------------------------------------------------*/
364 /*---------------------------------------------------------------------------*/
365 INT32 m2mb_heap_stat( UINT32 *total_bytes, UINT32 *free_bytes );
366 
370 /*-----------------------------------------------------------------------------------------------*/
371 
372 
373 #ifdef __cplusplus
374 }
375 #endif
376 #endif
VOID m2mb_heap_resetTrace(VOID)
m2mb_heap_resetTrace resets the current node in the list as the trace node.
unsigned char UINT8
Definition: m2mb_types.h:86
unsigned short UINT16
Definition: m2mb_types.h:87
Structure for node data.
Definition: m2mb_heap.h:74
struct M2MB_ALLOC_NODE_DATA M2MB_HEAP_ALLOC_NODE_DATA_T
Structure for node data.
void VOID
Definition: m2mb_types.h:74
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_ALL...
UINT32 m2mb_heap_getSize(UINT8 *ptr)
m2mb_heap_getSize returns the size of current node data in bytes.
unsigned long int UINT32
Definition: m2mb_types.h:88
signed int INT32
Definition: m2mb_types.h:82
void m2mb_heap_free(void *ptr, char *file, int line)
m2mb_heap_free is called to frees the memory pointed by ptr.
VOID m2mb_heap_log_init(VOID)
m2mb_heap_log_init is called to initialize the heap allocation list.
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...
INT32 m2mb_heap_stat(UINT32 *total_bytes, UINT32 *free_bytes)
m2mb_heap_stat is called to get the status.
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.