41 #ifndef LEGATO_MEMORY_H
42 #define LEGATO_MEMORY_H
46 #if LE_MEMORY_MANAGER_ENABLE == 1
48 #define LE_FIXED_HEAP_COUNT 7
53 typedef struct leVariableHeapUsageReport
58 } leVariableHeapUsageReport;
76 typedef struct leFixedHeapUsageReport
80 size_t currentCapacity;
82 } leFixedHeapUsageReport;
87 typedef struct leMemoryStatusReport
89 leVariableHeapUsageReport variableHeapReport;
90 leFixedHeapUsageReport fixedHeapReport[LE_FIXED_HEAP_COUNT - 1];
91 } leMemoryStatusReport;
104 #if LE_USE_DEBUG_ALLOCATOR == 1
105 #define LE_MALLOC(size) leMalloc(size, __LINE__, __FUNCTION__, __FILE__)
106 #define LE_REALLOC(ptr, size) leRealloc(ptr, size, __LINE__, __FUNCTION__, __FILE__)
108 #define LE_MALLOC(size) leMalloc(size)
109 #define LE_REALLOC(ptr, size) leRealloc(ptr, size)
112 #define LE_FREE(ptr) leFree(ptr)
114 #if LE_USE_DEBUG_ALLOCATOR == 1
124 LIB_EXPORT
void* leMalloc(
size_t size,
142 LIB_EXPORT
void* leRealloc(
void* ptr,
157 LIB_EXPORT
void leFree(
void* ptr);
168 LIB_EXPORT
void* leMalloc(
size_t size);
180 LIB_EXPORT
void* leRealloc(
void* ptr,
193 LIB_EXPORT
void leFree(
void* ptr);
205 LIB_EXPORT
void leMemoryGetUsageReport(leMemoryStatusReport* rpt);
208 LIB_EXPORT
void leMemoryDumpAllocations();
220 LIB_EXPORT
leResult leMemoryValidateHeaps();
226 #define LE_MALLOC(size) malloc(size)
227 #define LE_REALLOC(ptr, size) realloc(ptr, size)
228 #define LE_FREE(ptr) free(ptr)
229 #endif // LE_MEMORY_MANAGER_ENABLE