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