2023-08-30 16:21:18 +08:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
|
* umm_malloc.h - a memory allocator for embedded systems (microcontrollers)
|
|
|
|
|
*
|
|
|
|
|
* See copyright notice in LICENSE.TXT
|
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef UMM_MALLOC_H
|
|
|
|
|
#define UMM_MALLOC_H
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
|
2024-10-30 16:50:31 +08:00
|
|
|
typedef struct umm_heap_config {
|
|
|
|
|
void *pheap;
|
|
|
|
|
size_t heap_size;
|
|
|
|
|
uint16_t numblocks;
|
|
|
|
|
} umm_heap;
|
|
|
|
|
|
|
|
|
|
extern void umm_init_heap(umm_heap *heap, void *ptr, size_t size);
|
|
|
|
|
extern void umm_init(umm_heap *heap);
|
|
|
|
|
|
|
|
|
|
extern void *umm_malloc(umm_heap *heap, size_t size);
|
|
|
|
|
extern void *umm_calloc(umm_heap *heap, size_t num, size_t size);
|
|
|
|
|
extern void *umm_realloc(umm_heap *heap, void *ptr, size_t size);
|
|
|
|
|
extern void umm_free(umm_heap *heap, void *ptr);
|
|
|
|
|
extern void *umm_malloc_align(umm_heap *heap, size_t size, size_t align);
|
|
|
|
|
extern void umm_free_align(umm_heap *heap, void *ptr);
|
2023-08-30 16:21:18 +08:00
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /* UMM_MALLOC_H */
|