34#pragma clang diagnostic ignored "-Wc++98-compat"
51#pragma GCC diagnostic push
53#pragma GCC diagnostic ignored "-Wunused-parameter"
82 std::size_t block_padding = calc_block_padding (alignment);
84 alloc_size += block_padding;
85 alloc_size += chunk_offset;
87 std::size_t block_minchunk = calc_block_minchunk (block_padding);
90 chunk_t* chunk =
nullptr;
96 if (free_list_ ==
reinterpret_cast<chunk_t*
> (arena_addr_))
100 int rem =
static_cast<int> (chunk->size - alloc_size);
103 if ((
static_cast<std::size_t
> (rem)) >= block_minchunk)
110 chunk->size =
static_cast<std::size_t
> (rem);
114 reinterpret_cast<chunk_t *
> (
reinterpret_cast<char *
> (chunk)
116 chunk->size = alloc_size;
128 free_list_ = chunk->next;
135 if (chunk !=
nullptr)
140 if (out_of_memory_handler_ ==
nullptr)
142#if defined(OS_TRACE_LIBCPP_MEMORY_RESOURCE)
143 trace::printf (
"lifo::%s(%u,%u)=0 @%p %s\n", __func__, bytes,
144 alignment,
this, this->
name ());
150#if defined(OS_TRACE_LIBCPP_MEMORY_RESOURCE)
151 trace::printf (
"lifo::%s(%u,%u) @%p %s out of memory\n", __func__,
152 bytes, alignment,
this, this->
name ());
154 out_of_memory_handler_ ();
162#if defined(OS_TRACE_LIBCPP_MEMORY_RESOURCE)
163 trace::printf (
"lifo::%s(%u,%u)=%p,%u @%p %s\n", __func__, bytes,
164 alignment, aligned_payload, alloc_size,
this,
name ());
167 return aligned_payload;
170#pragma GCC diagnostic pop
void * internal_align_(chunk_t *chunk, std::size_t bytes, std::size_t alignment)
Internal function to align a chunk.
virtual ~lifo() override
Destruct the memory resource object instance.
virtual void * do_allocate(std::size_t bytes, std::size_t alignment) override
Implementation of the memory allocator.
const char * name(void) const
Get object name.
int printf(const char *format,...)
Write a formatted string to the trace device.
constexpr std::size_t align_size(std::size_t size, std::size_t align) noexcept
Helper function to align size values.
constexpr std::size_t max(std::size_t a, std::size_t b)