microui  14.1.1
microui
microui_heap.h
Go to the documentation of this file.
1 /*
2  * C
3  *
4  * Copyright 2021-2024 MicroEJ Corp. All rights reserved.
5  * Use of this source code is governed by a BSD-style license that can be found with this software.
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)
28 
29 // -----------------------------------------------------------------------------
30 // Includes
31 // -----------------------------------------------------------------------------
32 
33 #include <stdint.h>
34 
35 // -----------------------------------------------------------------------------
36 // API
37 // -----------------------------------------------------------------------------
38 
39 /*
40  * @brief Returns the MicroUI image heap size in bytes.
41  */
42 uint32_t MICROUI_HEAP_total_space(void);
43 
44 /*
45  * @brief Returns the MicroUI image heap free space size in bytes.
46  *
47  * Warnings: The total free space cannot contain a block whose size is equal to
48  * the total free space:
49  * - The best fit allocator adds a header and a footer for each allocated
50  * block.
51  * - Consecutive malloc/free produce cause memory fragmentation (all the free
52  * blocks are not contiguous in the memory). The function returns the sum of
53  * all the free blocks.
54  */
55 uint32_t MICROUI_HEAP_free_space(void);
56 
57 /*
58  * @brief Returns the number of blocks allocated.
59  *
60  * The MicroUI image heap is mainly used to allocate the pixels buffers of MicroUI
61  * ResourceImages (images decoded dynamically at runtime, copy of images located in
62  * a non-byte addressable memory, and MicroUI BufferedImages).
63  */
64 uint32_t MICROUI_HEAP_number_of_allocated_blocks(void);
65 
66 // -----------------------------------------------------------------------------
67 // EOF
68 // -----------------------------------------------------------------------------
69 
70 #endif // UI_FEATURE_ALLOCATOR
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif // MICROUI_HEAP_H
MicroEJ MicroUI library low level API: enable some features according to the hardware capabilities.