CppCommon
1.0.4.1
C++ Common Library
|
Stack memory manager class. More...
#include <allocator_stack.h>
Public Member Functions | |
StackMemoryManager () | |
StackMemoryManager (const StackMemoryManager &)=delete | |
StackMemoryManager (StackMemoryManager &&)=delete | |
~StackMemoryManager () noexcept | |
StackMemoryManager & | operator= (const StackMemoryManager &)=delete |
StackMemoryManager & | operator= (StackMemoryManager &&)=delete |
size_t | allocated () const noexcept |
Allocated memory in bytes. More... | |
size_t | allocations () const noexcept |
Count of active memory allocations. More... | |
const uint8_t * | buffer () const noexcept |
Stack buffer. More... | |
size_t | capacity () const noexcept |
Stack capacity. More... | |
size_t | size () const noexcept |
Stack allocated size. More... | |
size_t | max_size () const noexcept |
Maximum memory block size, that could be allocated by the memory manager. More... | |
void * | malloc (size_t size, size_t alignment=alignof(std::max_align_t)) |
Allocate a new memory block of the given size. More... | |
void | free (void *ptr, size_t size) |
Free the previously allocated memory block. More... | |
void | reset () |
Reset the memory manager. More... | |
Stack memory manager class.
Stack memory manager uses current stack buffer of the given size as a source of memory during the allocation.
When a new block of memory allocated then the stack free size is checked and the free offset is moved. If there is no enough space std::bad_alloc will be thrown or null is returned (depends on parameter).
Deallocate method does nothing. When the allocation/deallocation phase is finished then the free stack offset could be reset with a corresponding method.
Not thread-safe.
Definition at line 32 of file allocator_stack.h.
|
inline |
Definition at line 12 of file allocator_stack.inl.
|
delete |
|
delete |
|
inlinenoexcept |
Definition at line 38 of file allocator_stack.h.
|
inlinenoexcept |
Allocated memory in bytes.
Definition at line 44 of file allocator_stack.h.
|
inlinenoexcept |
Count of active memory allocations.
Definition at line 46 of file allocator_stack.h.
|
inlinenoexcept |
Stack buffer.
Definition at line 49 of file allocator_stack.h.
|
inlinenoexcept |
Stack capacity.
Definition at line 51 of file allocator_stack.h.
|
inline |
Free the previously allocated memory block.
ptr | - Pointer to the memory block |
size | - Block size |
Definition at line 48 of file allocator_stack.inl.
|
inline |
Allocate a new memory block of the given size.
size | - Block size |
alignment | - Block alignment (default is alignof(std::max_align_t)) |
Definition at line 21 of file allocator_stack.inl.
|
inlinenoexcept |
Maximum memory block size, that could be allocated by the memory manager.
Definition at line 56 of file allocator_stack.h.
|
delete |
|
delete |
|
inline |
Reset the memory manager.
Definition at line 61 of file allocator_stack.inl.
|
inlinenoexcept |
Stack allocated size.
Definition at line 53 of file allocator_stack.h.