The strategy used in z_heap_aligned_alloc() was to allocate an extra align-sized memory block for storing a pointer to the memory heap. This is wasteful in terms of memory usage when alignment is larger than a pointer width. A loop is needed to find the initial memory start when freeing it which isn't optimal either. Instead, let's have sys_heap_aligned_alloc() rewind a pointer after it is aligned to make just enough room for storing our heap reference. This way the heap reference is always located immediately before the aligned memory and any unused memory is returned to the heap. The rewind and alignment values may coincide in which case only the alignment is necessary anyway. Signed-off-by: Nicolas Pitre <npitre@baylibre.com> |
||
|---|---|---|
| .. | ||
| cmsis_rtos_v1 | ||
| cmsis_rtos_v2 | ||
| fnmatch | ||
| gui | ||
| libc | ||
| open-amp | ||
| os | ||
| posix | ||
| CMakeLists.txt | ||
| Kconfig | ||