6#include "dawn/porting/memory.hxx"
10#include <nuttx/mm/mm.h>
14static_assert(MM_ALIGN >= __STDCPP_DEFAULT_NEW_ALIGNMENT__,
15 "CONFIG_MM_DEFAULT_ALIGNMENT is below C++ new alignment");
22int memory_pool_init(
memory_pool_s *pool,
const char *name,
void *buffer,
size_t size)
24 if (pool ==
nullptr || buffer ==
nullptr || size == 0)
29 if (pool->heap !=
nullptr)
34 pool->heap = mm_initialize(name, buffer, size);
35 return pool->heap ==
nullptr ? -ENOMEM : OK;
42 if (pool ==
nullptr || pool->heap ==
nullptr || size == 0)
47 ptr = mm_malloc(
static_cast<mm_heap_s *
>(pool->heap), size);
50 std::memset(ptr, 0, size);
58 if (pool ==
nullptr || pool->heap ==
nullptr || ptr ==
nullptr)
63 mm_free(
static_cast<mm_heap_s *
>(pool->heap), ptr);
Out-of-tree user-extension hooks for Dawn.
Platform-backed memory pool handle.