Memory manager¶
-
group
LWESP_MEM
Dynamic memory manager.
Functions
-
uint8_t
lwesp_mem_assignmemory
(const lwesp_mem_region_t *regions, size_t size)¶ Assign memory region(s) for allocation functions.
- Note
You can allocate multiple regions by assigning start address and region size in units of bytes
- Return
1
on success,0
otherwise- Note
Function is not available when LWESP_CFG_MEM_CUSTOM is
1
- Parameters
[in] regions
: Pointer to list of regions to use for allocations[in] len
: Number of regions to use
-
void *
lwesp_mem_malloc
(size_t size)¶ Allocate memory of specific size.
- Return
Memory address on success,
NULL
otherwise- Note
Function is not available when LWESP_CFG_MEM_CUSTOM is
1
and must be implemented by user- Parameters
[in] size
: Number of bytes to allocate
-
void *
lwesp_mem_realloc
(void *ptr, size_t size)¶ Reallocate memory to specific size.
- Note
After new memory is allocated, content of old one is copied to new memory
- Return
Memory address on success,
NULL
otherwise- Note
Function is not available when LWESP_CFG_MEM_CUSTOM is
1
and must be implemented by user- Parameters
[in] ptr
: Pointer to current allocated memory to resize, returned using lwesp_mem_malloc, lwesp_mem_calloc or lwesp_mem_realloc functions[in] size
: Number of bytes to allocate on new memory
-
void *
lwesp_mem_calloc
(size_t num, size_t size)¶ Allocate memory of specific size and set memory to zero.
- Return
Memory address on success,
NULL
otherwise- Note
Function is not available when LWESP_CFG_MEM_CUSTOM is
1
and must be implemented by user- Parameters
[in] num
: Number of elements to allocate[in] size
: Size of each element
-
void
lwesp_mem_free
(void *ptr)¶ Free memory.
- Note
Function is not available when LWESP_CFG_MEM_CUSTOM is
1
and must be implemented by user- Parameters
[in] ptr
: Pointer to memory previously returned using lwesp_mem_malloc, lwesp_mem_calloc or lwesp_mem_realloc functions
-
uint8_t
lwesp_mem_free_s
(void **ptr)¶ Free memory in safe way by invalidating pointer after freeing.
- Return
1
on success,0
otherwise- Parameters
[in] ptr
: Pointer to pointer to allocated memory to free
-
struct
lwesp_mem_region_t
¶ - #include <lwesp_mem.h>
Single memory region descriptor.
-
uint8_t