31 #if !defined(CH_CFG_USE_HEAP) 32 #define CH_CFG_USE_HEAP FALSE 35 #if (CH_CFG_USE_HEAP == TRUE) || defined(__DOXYGEN__) 45 #if (SIZEOF_PTR == 4) || defined(__DOXYGEN__) 46 #define CH_HEAP_ALIGNMENT 8U 47 #elif (SIZEOF_PTR == 2) 48 #define CH_HEAP_ALIGNMENT 4U 50 #error "unsupported pointer size" 61 #if CH_CFG_USE_MEMCORE == FALSE 62 #error "CH_CFG_USE_HEAP requires CH_CFG_USE_MEMCORE" 65 #if (CH_CFG_USE_MUTEXES == FALSE) && (CH_CFG_USE_SEMAPHORES == FALSE) 66 #error "CH_CFG_USE_HEAP requires CH_CFG_USE_MUTEXES and/or CH_CFG_USE_SEMAPHORES" 104 #if CH_CFG_USE_MUTEXES == TRUE 118 #define CH_HEAP_AREA(name, size) \ 119 ALIGNED_VAR(CH_HEAP_ALIGNMENT) \ 120 uint8_t name[MEM_ALIGN_NEXT((size), CH_HEAP_ALIGNMENT)] static size_t chHeapGetSize(const void *p)
Returns the size of an allocated block.
memgetfunc2_t provider
Memory blocks provider for this heap.
heap_header_t header
Free blocks list header.
void chHeapFree(void *p)
Frees a previously allocated memory block.
#define CH_HEAP_ALIGNMENT
Minimum alignment used for heap.
void chHeapObjectInit(memory_heap_t *heapp, void *buf, size_t size)
Initializes a memory heap from a static memory area.
mutex_t mtx
Heap access mutex.
size_t chHeapStatus(memory_heap_t *heapp, size_t *totalp, size_t *largestp)
Reports the heap status.
static void * chHeapAlloc(memory_heap_t *heapp, size_t size)
Allocates a block of memory from the heap by using the first-fit algorithm.
void * chHeapAllocAligned(memory_heap_t *heapp, size_t size, unsigned align)
Allocates a block of memory from the heap by using the first-fit algorithm.
Structure describing a memory heap.
void *(* memgetfunc2_t)(size_t size, unsigned align, size_t offset)
Enhanced memory get function.
void _heap_init(void)
Initializes the default heap.