EasyGUI  Version v1.0
Memory management

Common memory management functions. More...

Data Structures

struct  mem_region_t
 Single memory region descriptor. More...
 

Typedefs

typedef mem_region_t GUI_MEM_Region_t
 Wrapper for memory region for GUI.
 

Functions

void * gui_mem_alloc (uint32_t size)
 Allocate memory of specific size. More...
 
void * gui_mem_realloc (void *ptr, size_t size)
 Allocate memory of specific size. More...
 
void * gui_mem_calloc (size_t num, size_t size)
 Allocate memory of specific size and set memory to zero. More...
 
void gui_mem_free (void *ptr)
 Free memory. More...
 
size_t gui_mem_getfree (void)
 Get total free size still available in memory to allocate. More...
 
size_t gui_mem_getfull (void)
 Get total currently allocated memory in regions. More...
 
size_t gui_mem_getminfree (void)
 Get minimal available number of bytes ever for allocation. More...
 
uint8_t gui_mem_assignmemory (const GUI_MEM_Region_t *regions, size_t size)
 Assign memory region(s) for allocation functions. More...
 

Detailed Description

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:

Note
All functions are thread safe and can be used by application if required

Function Documentation

◆ gui_mem_alloc()

void* gui_mem_alloc ( uint32_t  size)

Allocate memory of specific size.

Note
The function is private and can be called only when GUI protection against multiple access is activated
Parameters
[in]sizeNumber of bytes to allocate
Return values
0Allocation failed
>0Pointer to allocated memory

◆ gui_mem_assignmemory()

uint8_t gui_mem_assignmemory ( const GUI_MEM_Region_t regions,
size_t  len 
)

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]regionsPointer to list of regions to use for allocations
[in]lenNumber of regions to use
Return values
1Memory assigned ok
0Memory was not assigned

◆ gui_mem_calloc()

void* gui_mem_calloc ( size_t  num,
size_t  size 
)

Allocate memory of specific size and set memory to zero.

Note
The function is private and can be called only when GUI protection against multiple access is activated
Parameters
[in]numNumber of elements to allocate
[in]sizeSize of each element
Return values
0Allocation failed
>0Pointer to allocated memory

◆ gui_mem_free()

void gui_mem_free ( void *  ptr)

Free memory.

Parameters
[in]ptrPointer to memory previously returned using gui_mem_alloc, gui_mem_calloc or gui_mem_realloc functions

◆ gui_mem_getfree()

size_t gui_mem_getfree ( void  )

Get total free size still available in memory to allocate.

Note
The function is private and can be called only when GUI protection against multiple access is activated
Return values
Numberof bytes available to allocate

◆ gui_mem_getfull()

size_t gui_mem_getfull ( void  )

Get total currently allocated memory in regions.

Note
The function is private and can be called only when GUI protection against multiple access is activated
Return values
Numberof bytes in use

◆ gui_mem_getminfree()

size_t gui_mem_getminfree ( void  )

Get minimal available number of bytes ever for allocation.

Note
The function is private and can be called only when GUI protection against multiple access is activated
Return values
Numberof 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 allocated memory
The function is private and can be called only when GUI protection against multiple access is activated
Parameters
[in]ptrPointer to current allocated memory to resize, returned using gui_mem_alloc, gui_mem_calloc or gui_mem_realloc functions
[in]sizeNumber of bytes to allocate on new memory
Return values
0Allocation failed
>0Pointer to allocated memory