microui  14.5.1
microui
microui_heap.h
Go to the documentation of this file.
1 /*
2  * C
3  *
4  * Copyright 2021-2025 MicroEJ Corp. All rights reserved.
5  * MicroEJ Corp. PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */
7 
18 #if !defined MICROUI_HEAP_H
19 #define MICROUI_HEAP_H
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #include "ui_configuration.h"
26 
27 #if defined(UI_FEATURE_ALLOCATOR) && defined(UI_FEATURE_ALLOCATOR_BESTFIT) && \
28  (UI_FEATURE_ALLOCATOR == UI_FEATURE_ALLOCATOR_BESTFIT)
29 
30 // -----------------------------------------------------------------------------
31 // Includes
32 // -----------------------------------------------------------------------------
33 
34 #include <stdint.h>
35 
36 // -----------------------------------------------------------------------------
37 // API
38 // -----------------------------------------------------------------------------
39 
40 /*
41  * @brief Returns the MicroUI image heap size in bytes.
42  */
43 uint32_t MICROUI_HEAP_total_space(void);
44 
45 /*
46  * @brief Returns the MicroUI image heap free space size in bytes.
47  *
48  * Warnings: The total free space cannot contain a block whose size is equal to
49  * the total free space:
50  * - The best fit allocator adds a header and a footer for each allocated
51  * block.
52  * - Consecutive malloc/free produce cause memory fragmentation (all the free
53  * blocks are not contiguous in the memory). The function returns the sum of
54  * all the free blocks.
55  */
56 uint32_t MICROUI_HEAP_free_space(void);
57 
58 /*
59  * @brief Returns the number of blocks allocated.
60  *
61  * The MicroUI image heap is mainly used to allocate the pixels buffers of MicroUI
62  * ResourceImages (images decoded dynamically at runtime, copy of images located in
63  * a non-byte addressable memory, and MicroUI BufferedImages).
64  */
65 uint32_t MICROUI_HEAP_number_of_allocated_blocks(void);
66 
67 // -----------------------------------------------------------------------------
68 // EOF
69 // -----------------------------------------------------------------------------
70 
71 #endif // UI_FEATURE_ALLOCATOR
72 
73 #ifdef __cplusplus
74 }
75 #endif
76 
77 #endif // MICROUI_HEAP_H
MicroEJ MicroUI library low level API: enable some features according to the hardware capabilities.