84#define HEAPMEM_DEBUG 0
87typedef struct heapmem_stats {
96typedef uint8_t heapmem_zone_t;
98#define HEAPMEM_ZONE_INVALID (heapmem_zone_t)-1
99#define HEAPMEM_ZONE_GENERAL 0
114#define heapmem_alloc(size) \
115 heapmem_zone_alloc_debug(HEAPMEM_ZONE_GENERAL, (size), __FILE__, __LINE__)
116#define heapmem_zone_alloc(zone, size) \
117 heapmem_zone_alloc_debug((zone), (size), __FILE__, __LINE__)
118#define heapmem_realloc(ptr, size) \
119 heapmem_realloc_debug((ptr), (size), __FILE__, __LINE__)
120#define heapmem_calloc(nmemb, size) \
121 heapmem_calloc_debug((nmemb), (size), __FILE__, __LINE__)
122#define heapmem_free(ptr) \
123 heapmem_free_debug((ptr), __FILE__, __LINE__)
125void *heapmem_alloc_debug(
size_t size,
126 const char *file,
const unsigned line);
127void *heapmem_zone_alloc_debug(heapmem_zone_t zone,
size_t size,
128 const char *file,
const unsigned line);
129void *heapmem_realloc_debug(
void *ptr,
size_t size,
130 const char *file,
const unsigned line);
131void *heapmem_calloc_debug(
size_t nmemb,
size_t size,
132 const char *file,
const unsigned line);
133bool heapmem_free_debug(
void *ptr,
134 const char *file,
const unsigned line);
147#define heapmem_alloc(size) heapmem_zone_alloc(HEAPMEM_ZONE_GENERAL, (size))
void * heapmem_zone_alloc(heapmem_zone_t zone, size_t size)
Allocate a chunk of memory in the heap.
void * heapmem_realloc(void *ptr, size_t size)
Reallocate a chunk of memory in the heap.
heapmem_zone_t heapmem_zone_register(const char *name, size_t zone_size)
Register a zone with a reserved subdivision of the heap.
void heapmem_stats(heapmem_stats_t *stats)
Obtain internal heapmem statistics regarding the allocated chunks.
size_t heapmem_alignment(void)
Obtain the minimum alignment of allocated addresses.
bool heapmem_free(void *ptr)
Deallocate a chunk of memory.
void heapmem_print_debug_info(bool print_chunks)
Print debugging information for the heap memory management.
void * heapmem_calloc(size_t nmemb, size_t size)
Allocate memory for a zero-initialized array.