This API provides an interface for a general purpose dynamic memory manager. More...
Macros | |
#define | MESH_MEM_SIZE_MIN NRF_MESH_UPPER_TRANSPORT_PDU_SIZE_MAX |
The smallest size of dynamic memory that the mesh requires to operate. More... | |
Functions | |
void | mesh_mem_init (void) |
Initialize the memory manager. More... | |
void * | mesh_mem_alloc (size_t size) |
Allocate size bytes and return a pointer to the allocated memory. More... | |
void | mesh_mem_free (void *ptr) |
Free the allocated memory. More... | |
void * | mesh_mem_calloc (size_t nmemb, size_t size) |
Allocate memory for an array of nmemb elements of size bytes. More... | |
This API provides an interface for a general purpose dynamic memory manager.
The API resembles the standard malloc()/calloc()/free() interface.
The standard library dynamic memory allocation functions are not used directly to allow the user to use a different memory management backend than the one that the standard library provides.
To change the memory management backend, replace the mesh_mem_<backend>.c
to the desired implementation. The default backend is mesh_mem_stdlib.c
.
#define MESH_MEM_SIZE_MIN NRF_MESH_UPPER_TRANSPORT_PDU_SIZE_MAX |
The smallest size of dynamic memory that the mesh requires to operate.
If the dynamic memory available is less than NRF_MESH_UPPER_TRANSPORT_PDU_SIZE_MAX, the device cannot receive full length upper transport PDUs and may not function properly.
Definition at line 66 of file mesh_mem.h.
void mesh_mem_init | ( | void | ) |
Initialize the memory manager.
void* mesh_mem_alloc | ( | size_t | size | ) |
Allocate size
bytes and return a pointer to the allocated memory.
[in] | size | Size in bytes of the memory to allocate. |
NULL
if no memory was allocated. void mesh_mem_free | ( | void * | ptr | ) |
Free the allocated memory.
[in] | ptr | Pointer to memory that shall be freed. The pointer must be previously allocated by a call to mesh_mem_alloc() or mesh_mem_calloc(). Otherwise, the behavior is undefined. |
void* mesh_mem_calloc | ( | size_t | nmemb, |
size_t | size | ||
) |
Allocate memory for an array of nmemb
elements of size
bytes.
[in] | nmemb | Number of members in the array. |
[in] | size | Size in bytes of the individual members. |
NULL
if no memory was allocated.