28#ifndef CMSIS_PLUS_MEMORY_MALLOC_H_
29#define CMSIS_PLUS_MEMORY_MALLOC_H_
33#if defined(__cplusplus)
41#pragma GCC diagnostic push
44#pragma clang diagnostic ignored "-Wc++98-compat"
54#pragma GCC diagnostic push
56#pragma clang diagnostic ignored "-Wweak-vtables"
130 do_allocate (std::size_t bytes, std::size_t alignment)
override;
141 do_deallocate (
void* addr, std::size_t bytes, std::size_t alignment)
194 do_allocate (
size_t bytes,
size_t alignment)
override;
214#pragma GCC diagnostic pop
237 rtos::memory::memory_resource
240 trace::printf (
"%s() @%p %s\n", __func__,
this, this->name ());
249#pragma GCC diagnostic push
251#pragma GCC diagnostic ignored "-Wunused-parameter"
255 std::size_t alignment)
258 void* mem = std::malloc (bytes);
259#if defined(OS_TRACE_LIBCPP_MEMORY_RESOURCE)
260 trace::printf (
"%s(%u,%u)=%p @%p %s\n", __func__, bytes, alignment, mem,
269 std::size_t alignment)
noexcept
271#if defined(OS_TRACE_LIBCPP_MEMORY_RESOURCE)
272 trace::printf (
"%s(%p,%u,%u) @%p %s\n", __func__, addr, bytes, alignment,
279#pragma GCC diagnostic pop
283#pragma GCC diagnostic push
285#pragma GCC diagnostic ignored "-Wunused-parameter"
291 void* mem = ::operator
new (bytes);
292#if defined(OS_TRACE_LIBCPP_MEMORY_RESOURCE)
293 trace::printf (
"%s(%u,%u)=%p @%p %s\n", __func__, bytes, alignment, mem,
302 size_t alignment)
noexcept
304#if defined(OS_TRACE_LIBCPP_MEMORY_RESOURCE)
305 trace::printf (
"%s(%p,%u,%u) @%p %s\n", __func__, addr, bytes, alignment,
309 ::operator
delete (addr);
313#pragma GCC diagnostic pop
319#pragma GCC diagnostic pop
A memory manager that allocates memory via the system std::malloc() and deallocates via std::free().
malloc_memory_resource()
Default constructor. Construct a memory manager object instance.
virtual void do_deallocate(void *addr, std::size_t bytes, std::size_t alignment) noexcept override
Implementation of the memory deallocator.
virtual void * do_allocate(std::size_t bytes, std::size_t alignment) override
Implementation of the memory allocator.
~malloc_memory_resource() override
Destruct the memory manager object instance.
A memory manager that allocates memory via the system operator new and deallocates via operator delet...
~new_delete_memory_resource() override=default
Destruct the memory manager object instance.
virtual void * do_allocate(size_t bytes, size_t alignment) override
Implementation of the memory allocator.
virtual void do_deallocate(void *addr, size_t bytes, size_t alignment) noexcept override
Implementation of the memory deallocator.
const char * name(void) const
Get object name.
Memory resource manager (abstract class).
int printf(const char *format,...)
Write a formatted string to the trace device.
Single file µOS++ RTOS definitions.