Fling Engine  0.00.1
Fling Engine is a game engine written in Vulkan
Public Member Functions | Private Attributes
Fling::StackAllocator Class Reference

#include <StackAllocator.h>

Public Member Functions

 StackAllocator (void *t_Start, void *t_End)
 Construct a new Stack Allocator object. More...
 
 ~StackAllocator ()
 
void * Allocate (size_t t_Size, size_t t_Alignment=0, size_t t_Offset=0)
 
void Free (void *t_Ptr)
 Returns a block of memory to the stack in a LIFO manner. More...
 

Private Attributes

char * m_Start = nullptr
 
char * m_End = nullptr
 
char * m_Current = nullptr
 

Detailed Description

See also
https://blog.molecular-matters.com/2012/08/27/memory-allocation-strategies-a-stack-like-lifo-allocator/

Constructor & Destructor Documentation

◆ StackAllocator()

Fling::StackAllocator::StackAllocator ( void *  t_Start,
void *  t_End 
)

Construct a new Stack Allocator object.

Parameters
t_StartStart of the memory block to use for this stack allocator
t_EndEnd of the memory block to use for this stack allocator

◆ ~StackAllocator()

Fling::StackAllocator::~StackAllocator ( )

Member Function Documentation

◆ Allocate()

void * Fling::StackAllocator::Allocate ( size_t  t_Size,
size_t  t_Alignment = 0,
size_t  t_Offset = 0 
)
Parameters
t_SizeSize of the block of memory
t_AlignmentAlignment of the element (Default = 8)
t_OffsetOffset of the element (Default = 0)
Returns
void* Obtain a chunk of memory of the size, alignment, and offset (asserts when we exceed preallocated size)

◆ Free()

void Fling::StackAllocator::Free ( void *  t_Ptr)

Returns a block of memory to the stack in a LIFO manner.

Parameters
t_Ptr

Field Documentation

◆ m_Current

char* Fling::StackAllocator::m_Current = nullptr
private

◆ m_End

char* Fling::StackAllocator::m_End = nullptr
private

◆ m_Start

char* Fling::StackAllocator::m_Start = nullptr
private

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