#include <playrho/StackAllocator.hpp>
Classes | |
struct | Conf |
Stack allocator configuration data. More... | |
Public Types | |
using | size_type = std::size_t |
Size type. | |
Public Member Functions | |
StackAllocator (const Conf &config=GetDefaultConf()) | |
Initializing constructor. | |
StackAllocator (const StackAllocator ©)=delete | |
Copy constructor. | |
StackAllocator (StackAllocator &&other)=delete | |
void * | Allocate (size_type size) |
template<typename T > | |
T * | AllocateArray (size_type size) |
Allocates and array of the given size number of elements. | |
void | Free (void *p) noexcept |
Frees the given pointer. | |
auto | GetAllocation () const noexcept |
Gets the total number of bytes that this object has currently allocated. | |
auto | GetEntryCount () const noexcept |
auto | GetIndex () const noexcept |
auto | GetMaxAllocation () const noexcept |
Gets the max allocation. | |
auto | GetMaxEntries () const noexcept |
Gets the max entries. | |
auto | GetPreallocatedSize () const noexcept |
Gets the preallocated size. | |
void | operator() (void *p) noexcept |
StackAllocator & | operator= (const StackAllocator &other)=delete |
Copy assignment operator. | |
StackAllocator & | operator= (StackAllocator &&other)=delete |
Static Public Member Functions | |
static constexpr Conf | GetDefaultConf () |
Gets the default configuration. | |
Stack allocator.
This is a stack allocator used for fast per step allocations. You must nest allocate/free pairs. The code will assert if you try to interleave multiple allocate/free pairs.
std::unique_ptr()
Deleter requirement. void * StackAllocator::Allocate | ( | size_type | size | ) |
Allocates an aligned block of memory of the given size.
nullptr
otherwise. Referenced by AllocateArray().
|
inlinenoexcept |
Gets the current allocation record entry usage count.
|
inlinenoexcept |
Gets the current index location.
This represents the number of bytes used (of the storage allocated at construction time by this object). Storage remaining is calculated by subtracting this value from StackSize
.
StackSize
.
|
inlinenoexcept |
Functional operator for freeing memory allocated by this object.
This function frees memory (like called Free) and allows this object to be used as deleter to std::unique_ptr
.