22 #if defined(UI_FEATURE_ALLOCATOR) && defined(UI_FEATURE_ALLOCATOR_BESTFIT) && \
23 (UI_FEATURE_ALLOCATOR == UI_FEATURE_ALLOCATOR_BESTFIT)
30 #include "BESTFIT_ALLOCATOR.h"
39 #define BESTFITALLOCATOR_HEADER_SIZE (68)
46 #define BESTFITALLOCATOR_BLOCK_SIZE(block) ((*(uint32_t *)((block) - sizeof(uint32_t))) & 0x7ffffff)
52 static BESTFIT_ALLOCATOR image_heap;
53 static uint32_t heap_size;
54 static uint32_t free_space;
55 static uint32_t allocated_blocks_number;
61 uint32_t MICROUI_HEAP_total_space(
void) {
65 uint32_t MICROUI_HEAP_free_space(
void) {
69 uint32_t MICROUI_HEAP_number_of_allocated_blocks(
void) {
70 return allocated_blocks_number;
77 void LLUI_DISPLAY_IMPL_imageHeapInitialize(uint8_t *heap_start, uint8_t *heap_limit) {
78 heap_size = heap_limit - heap_start - BESTFITALLOCATOR_HEADER_SIZE;
79 free_space = heap_size;
80 BESTFIT_ALLOCATOR_new(&image_heap);
81 BESTFIT_ALLOCATOR_initialize(&image_heap, (int32_t)heap_start, (int32_t)heap_limit);
84 uint8_t * LLUI_DISPLAY_IMPL_imageHeapAllocate(uint32_t size) {
85 uint8_t *addr = (uint8_t *)BESTFIT_ALLOCATOR_allocate(&image_heap, (int32_t)size);
88 free_space -= BESTFITALLOCATOR_BLOCK_SIZE(addr);
89 allocated_blocks_number++;
94 void LLUI_DISPLAY_IMPL_imageHeapFree(uint8_t *block) {
95 free_space += BESTFITALLOCATOR_BLOCK_SIZE(block);
96 allocated_blocks_number--;
97 BESTFIT_ALLOCATOR_free(&image_heap, (
void *)block);
Provides some API to analyse the MicroUI image heap. The default allocator available in the Graphics ...
MicroEJ MicroUI library low level API: enable some features according to the hardware capabilities.