Common
The C Programming Language
Built-in Functions
__builtin_ffs()
__builtin_clz()
Zephyr
Dynamic Memory Allocation
Zephyr provides both libc
malloc()
and its own k_melloc()
functions for dynamic memory allocation. It replaces the common libc
implementations with its own one as described in Zephyr documentation.
However, malloc()
does not share the same heap with k_melloc()
[1], namely enabling one does not necessarily enable the other.
malloc()
can be enabled by setting the Kconfig option
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE
to a non-zero value. By the same token, k_melloc()
can be enabled by
setting the Kconfig option CONFIG_HEAP_MEM_POOL_SIZE
to a non-zero value.