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... | |
Detailed Description
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.
Macro Definition Documentation
◆ MESH_MEM_SIZE_MIN
| #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.
Function Documentation
◆ mesh_mem_init()
| void mesh_mem_init | ( | void | ) |
Initialize the memory manager.
- Note
- This API is called by nrf_mesh_init().
◆ mesh_mem_alloc()
| void* mesh_mem_alloc | ( | size_t | size | ) |
Allocate size bytes and return a pointer to the allocated memory.
- Note
- The memory is not initialized.
- Parameters
-
[in] size Size in bytes of the memory to allocate.
- Returns
- A pointer to the allocated memory, or
NULLif no memory was allocated.
◆ mesh_mem_free()
| void mesh_mem_free | ( | void * | ptr | ) |
Free the allocated memory.
- Parameters
-
[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.
◆ mesh_mem_calloc()
| void* mesh_mem_calloc | ( | size_t | nmemb, |
| size_t | size | ||
| ) |
Allocate memory for an array of nmemb elements of size bytes.
- Note
- The memory returned is set to zero.
- Parameters
-
[in] nmemb Number of members in the array. [in] size Size in bytes of the individual members.
- Returns
- A pointer to the allocated memory, or
NULLif no memory was allocated.