#include <StackAllocator.hpp>

Classes

struct  Conf
 Stack allocator configuration data. More...
 

Public Types

using size_type = std::size_t
 Size type. More...
 

Public Member Functions

 StackAllocator (Conf config=GetDefaultConf()) noexcept
 Initializing constructor. More...
 
 ~StackAllocator () noexcept
 
 StackAllocator (const StackAllocator &copy)=delete
 Copy constructor. More...
 
 StackAllocator (StackAllocator &&other)=delete
 
StackAllocatoroperator= (const StackAllocator &other)=delete
 Copy assignment operator. More...
 
StackAllocatoroperator= (StackAllocator &&other)=delete
 
void * Allocate (size_type size) noexcept
 
void Free (void *p) noexcept
 Frees the given pointer. More...
 
template<typename T >
T * AllocateArray (size_type size) noexcept
 Allocates and array of the given size number of elements. More...
 
void operator() (void *p) noexcept
 
auto GetMaxAllocation () const noexcept
 Gets the max allocation. More...
 
auto GetEntryCount () const noexcept
 
auto GetIndex () const noexcept
 
auto GetAllocation () const noexcept
 Gets the total number of bytes that this object has currently allocated. More...
 
auto GetPreallocatedSize () const noexcept
 Gets the preallocated size. More...
 
auto GetMaxEntries () const noexcept
 Gets the max entries. More...
 

Static Public Member Functions

static PLAYRHO_CONSTEXPR Conf GetDefaultConf ()
 Gets the default configuration. More...
 

Detailed Description

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.

Note
This class satisfies the C++11 std::unique_ptr() Deleter concept.
This data structure is 64-bytes large (on at least one 64-bit platform).

Definition at line 34 of file StackAllocator.hpp.

Member Typedef Documentation

◆ size_type

Size type.

Definition at line 39 of file StackAllocator.hpp.

Constructor & Destructor Documentation

◆ StackAllocator() [1/3]

StackAllocator::StackAllocator ( Conf  config = GetDefaultConf())
explicitnoexcept

Initializing constructor.

Definition at line 39 of file StackAllocator.cpp.

◆ ~StackAllocator()

StackAllocator::~StackAllocator ( )
noexcept

Definition at line 48 of file StackAllocator.cpp.

◆ StackAllocator() [2/3]

playrho::StackAllocator::StackAllocator ( const StackAllocator copy)
delete

Copy constructor.

◆ StackAllocator() [3/3]

playrho::StackAllocator::StackAllocator ( StackAllocator &&  other)
delete

Member Function Documentation

◆ GetDefaultConf()

static PLAYRHO_CONSTEXPR Conf playrho::StackAllocator::GetDefaultConf ( )
inlinestatic

Gets the default configuration.

Definition at line 49 of file StackAllocator.hpp.

◆ operator=() [1/2]

StackAllocator& playrho::StackAllocator::operator= ( const StackAllocator other)
delete

Copy assignment operator.

◆ operator=() [2/2]

StackAllocator& playrho::StackAllocator::operator= ( StackAllocator &&  other)
delete

◆ Allocate()

void * StackAllocator::Allocate ( size_type  size)
noexcept

Allocates an aligned block of memory of the given size.

Returns
Pointer to memory if the allocator has allocation records left, nullptr otherwise.
See also
GetEntryCount.

Definition at line 56 of file StackAllocator.cpp.

◆ Free()

void StackAllocator::Free ( void *  p)
noexcept

Frees the given pointer.

Definition at line 90 of file StackAllocator.cpp.

◆ AllocateArray()

template<typename T >
T* playrho::StackAllocator::AllocateArray ( size_type  size)
inlinenoexcept

Allocates and array of the given size number of elements.

Definition at line 80 of file StackAllocator.hpp.

◆ operator()()

void playrho::StackAllocator::operator() ( void *  p)
inlinenoexcept

Functional operator for freeing memory allocated by this object.

This method frees memory (like called Free) and allows this object to be used as deleter to std::unique_ptr.

Definition at line 88 of file StackAllocator.hpp.

◆ GetMaxAllocation()

auto playrho::StackAllocator::GetMaxAllocation ( ) const
inlinenoexcept

Gets the max allocation.

Definition at line 94 of file StackAllocator.hpp.

◆ GetEntryCount()

auto playrho::StackAllocator::GetEntryCount ( ) const
inlinenoexcept

Gets the current allocation record entry usage count.

Returns
Value between 0 and the maximum number of entries possible for this allocator.
See also
GetMaxEntries.

Definition at line 102 of file StackAllocator.hpp.

◆ GetIndex()

auto playrho::StackAllocator::GetIndex ( ) const
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.

Returns
Value between 0 and StackSize.

Definition at line 112 of file StackAllocator.hpp.

◆ GetAllocation()

auto playrho::StackAllocator::GetAllocation ( ) const
inlinenoexcept

Gets the total number of bytes that this object has currently allocated.

Definition at line 118 of file StackAllocator.hpp.

◆ GetPreallocatedSize()

auto playrho::StackAllocator::GetPreallocatedSize ( ) const
inlinenoexcept

Gets the preallocated size.

Definition at line 124 of file StackAllocator.hpp.

◆ GetMaxEntries()

auto playrho::StackAllocator::GetMaxEntries ( ) const
inlinenoexcept

Gets the max entries.

Definition at line 130 of file StackAllocator.hpp.


The documentation for this class was generated from the following files: