Memory
Basic memory allocation/loading functions. More...
Functions | |
zos_result_t | zn_malloc (uint8_t **ptr, uint32_t size) |
Allocate memory on the heap. More... | |
void * | zn_malloc_ptr (uint32_t size) |
Allocate memory on the heap. More... | |
zos_result_t | zn_free (void *ptr) |
Free memory allocated by zn_malloc() More... | |
void | zn_free_linked_list (void *list) |
Free the entries allocated in a linked listThe entries of the linked list should be of the form: More... | |
zos_result_t | zn_load_ro_memory (void *dst, uint32_t dst_length, const void *ro_mem, uint32_t ro_mem_offset) |
Load Read-Only memory from serial flash into RAM bufferWhen declaring a global data structure, the RO_MEM attribute may be used specify that structure to only reside in the ZAP's serial flash (i.e. More... | |
Detailed Description
Basic memory allocation/loading functions.
Function Documentation
zos_result_t zn_free | ( | void * | ptr | ) |
Free memory allocated by zn_malloc()
- Parameters
-
[in] ptr
Address returned by zn_malloc()
- Returns
- zos_result_t result of api call
void zn_free_linked_list | ( | void * | list | ) |
Free the entries allocated in a linked listThe entries of the linked list should be of the form:
i.e. The first element of each entry should point to the next entry in the list. The 'next' element of the last entry should be NULL.
- Parameters
-
[in] list
Linked list to de-allocate
zos_result_t zn_load_ro_memory | ( | void * | dst, |
uint32_t | dst_length, |
||
const void * | ro_mem, |
||
uint32_t | ro_mem_offset |
||
) |
Load Read-Only memory from serial flash into RAM bufferWhen declaring a global data structure, the RO_MEM attribute may be used specify that structure to only reside in the ZAP's serial flash (i.e.
read-only memory). For large, rarely read data structures this can save on RAM usage (recall sizeof(RAM) << sizeof(serial flash))
This is the API to load the read-only memory into RAM.
- Parameters
-
[out] dst
Destination RAM buffer address [in] dst_length
The size of destination buffer (i.e. the size of RO memory to load) [in] ro_mem
Source read-only memory address [in] ro_mem_offset
Offset from beginning of ro_mem address to begin loading
- Returns
- zos_result_t result of api call
zos_result_t zn_malloc | ( | uint8_t ** | ptr, |
uint32_t | size |
||
) |
Allocate memory on the heap.
If the memory is allocated, it is set to zero first. If this call fails, ptr will contain a NULL pointer. Use zn_free() to release the memory allocated by this function.
- Parameters
-
[out] ptr
Pointer to hold address of allocated data [in] size
Size of memory in bytes to allocated
- Returns
- zos_result_t result of api call
void* zn_malloc_ptr | ( | uint32_t | size | ) |
Allocate memory on the heap.
This has the exact same functionality as zn_malloc() except it directly returns the allocated function pointer. If this call fails, the return value is NULL. Use zn_free() to release the memory allocated by this function.
- Parameters
-
[in] size
Size of memory in bytes to allocated
- Returns
- Pointer to allocated memory, NULL on failure