Common memory management functions.
More...
Common memory management functions.
Since dynamic allocation can be hard job for some microcontrollers, library implements memory management parts with simple allocation process in different regions.
Memory management mode allows allocation of different sizes and allows free memory. It also takes cover to free memory and to create one big block if multiple regions are freed in sequence
Memory management can be used in multiple regions which may optimize RAM usage, for example:
- Use TCM/CCM RAM for widget structures (low amount of bytes, up to ~150, but depends on widget)
- Use of large amount of memory (ex. temporary frame buffers) on external RAM (SDRAM) module if supported by embedded device
- Note
- All functions are thread safe and can be used by application if required
◆ gui_mem_alloc()
| void* gui_mem_alloc |
( |
uint32_t |
size | ) |
|
Allocate memory of specific size.
- Note
- This function is private and may be called only when OS protection is active
- Parameters
-
| [in] | size | Number of bytes to allocate |
- Returns
- Allocated memory on success,
NULL otherwise
◆ gui_mem_assignmemory()
Assign memory region(s) for allocation functions.
- Note
- You can allocate multiple regions by assigning start address and region size in units of bytes
- Parameters
-
| [in] | regions | Pointer to list of regions to use for allocations |
| [in] | len | Number of regions to use |
- Returns
1 on success, 0 otherwise
◆ gui_mem_calloc()
| void* gui_mem_calloc |
( |
size_t |
num, |
|
|
size_t |
size |
|
) |
| |
Allocate memory of specific size and set memory to zero.
- Parameters
-
| [in] | num | Number of elements to allocate |
| [in] | size | Size of each element |
- Returns
- Allocated memory on success,
NULL otherwise
◆ gui_mem_free()
| void gui_mem_free |
( |
void * |
ptr | ) |
|
◆ gui_mem_getfree()
| size_t gui_mem_getfree |
( |
void |
| ) |
|
Get total free size still available in memory to allocate.
- Note
- This function is private and may be called only when OS protection is active
- Returns
- Number of bytes available to allocate
◆ gui_mem_getfull()
| size_t gui_mem_getfull |
( |
void |
| ) |
|
Get total currently allocated memory in regions.
- Note
- This function is private and may be called only when OS protection is active
- Returns
- Number of bytes in use
◆ gui_mem_getminfree()
| size_t gui_mem_getminfree |
( |
void |
| ) |
|
Get minimal available number of bytes ever for allocation.
- Note
- This function is private and may be called only when OS protection is active
- Returns
- Number of minimal available number of bytes ever
◆ gui_mem_realloc()
| void* gui_mem_realloc |
( |
void * |
ptr, |
|
|
size_t |
size |
|
) |
| |
Allocate memory of specific size.
- Note
- After new memory is allocated, content of old one is copied to new memory
- Parameters
-
- Returns
- Allocated memory on success,
NULL otherwise