microui  3.0.0
microui
microui_heap.h
1 /*
2  * C
3  *
4  * Copyright 2021-2023 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 
8 /*
9  * @file
10  * @brief See LLUI_DISPLAY_HEAP_impl.c.
11  * @author MicroEJ Developer Team
12  * @version 3.0.0
13  * @since MicroEJ UI Pack 13.1.0
14  */
15 
16 #if !defined MICROUI_HEAP_H
17 #define MICROUI_HEAP_H
18 
19 // -----------------------------------------------------------------------------
20 // Includes
21 // -----------------------------------------------------------------------------
22 
23 #include <stdint.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 // -----------------------------------------------------------------------------
30 // API
31 // -----------------------------------------------------------------------------
32 
33 /*
34  * @brief Returns the MicroUI image heap size in bytes.
35  */
36 uint32_t MICROUI_HEAP_total_space(void);
37 
38 /*
39  * @brief Returns the MicroUI image heap free space size in bytes.
40  *
41  * Warnings: The total free space cannot contain a block whose size is equal to
42  * the total free space:
43  * - The best fit allocator adds a header and a footer for each allocated
44  * block.
45  * - Consecutive malloc/free produce cause memory fragmentation (all the free
46  * blocks are not contiguous in the memory). The function returns the sum of
47  * all the free blocks.
48  */
49 uint32_t MICROUI_HEAP_free_space(void);
50 
51 /*
52  * @brief Returns the number of blocks allocated.
53  *
54  * The MicroUI image heap is mainly used to allocate the pixels buffers of MicroUI
55  * ResourceImages (images decoded dynamically at runtime, copy of images located in
56  * a non-byte addressable memory, and MicroUI BufferedImages).
57  */
58 uint32_t MICROUI_HEAP_number_of_allocated_blocks(void);
59 
60 // -----------------------------------------------------------------------------
61 // EOF
62 // -----------------------------------------------------------------------------
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 #endif // MICROUI_HEAP_H