9 #ifndef CPPCOMMON_MEMORY_ALLOCATOR_ARENA_H
10 #define CPPCOMMON_MEMORY_ALLOCATOR_ARENA_H
28 template <
class TAuxMemoryManager = DefaultMemoryManager>
60 size_t allocated() const noexcept {
return _allocated; }
65 const uint8_t*
buffer() const noexcept {
return _buffer; }
67 size_t capacity() const noexcept {
return _capacity; }
69 size_t size() const noexcept {
return _size; }
72 size_t max_size() const noexcept {
return _auxiliary.max_size(); }
75 TAuxMemoryManager&
auxiliary() noexcept {
return _auxiliary; }
83 void*
malloc(
size_t size,
size_t alignment =
alignof(std::max_align_t));
123 TAuxMemoryManager& _auxiliary;
136 Page* AllocateArena(
size_t capacity, Page* prev);
142 template <
typename T,
class TAuxMemoryManager = DefaultMemoryManager,
bool nothrow = false>
Memory allocator definition.
Arena memory allocator inline implementation.
Arena memory manager class.
void clear()
Clear arena memory allocator.
void reset()
Reset the memory manager.
size_t allocations() const noexcept
Count of active memory allocations.
size_t size() const noexcept
Arena allocated size.
ArenaMemoryManager & operator=(ArenaMemoryManager &&)=delete
void * malloc(size_t size, size_t alignment=alignof(std::max_align_t))
Allocate a new memory block of the given size.
ArenaMemoryManager & operator=(const ArenaMemoryManager &)=delete
ArenaMemoryManager(ArenaMemoryManager &&)=delete
size_t allocated() const noexcept
Allocated memory in bytes.
size_t capacity() const noexcept
Arena capacity.
ArenaMemoryManager(const ArenaMemoryManager &)=delete
TAuxMemoryManager & auxiliary() noexcept
Auxiliary memory manager.
void free(void *ptr, size_t size)
Free the previously allocated memory block.
size_t max_size() const noexcept
Maximum memory block size, that could be allocated by the memory manager.
ArenaMemoryManager(TAuxMemoryManager &auxiliary)
Initialize arena memory manager with an auxiliary memory manager.
const uint8_t * buffer() const noexcept
Arena buffer.
C++ Common project definitions.