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

Helpful for allocating/freeing objects of a certain size which have to be created/destroeyed dynamically. More...

#include <FreeList.h>

Public Member Functions

 FreeList (void *t_Start, void *t_End, size_t t_ElmSize, size_t t_Alignment=8, size_t t_Offset=0)
 Construct a new Free List object. More...
 
void * Obtain () noexcept
 Obtain a chunk of memory of the size and alignment that this list was created with. More...
 
void Return (void *t_Ptr)
 Return a block of memory to the free list. More...
 

Private Attributes

FreeListm_Next = nullptr
 Alias in memory to the next available block. More...
 

Detailed Description

Helpful for allocating/freeing objects of a certain size which have to be created/destroeyed dynamically.

See also
https://blog.molecular-matters.com/2012/09/17/memory-allocation-strategies-a-pool-allocator/

Constructor & Destructor Documentation

◆ FreeList()

Fling::FreeList::FreeList ( void *  t_Start,
void *  t_End,
size_t  t_ElmSize,
size_t  t_Alignment = 8,
size_t  t_Offset = 0 
)

Construct a new Free List object.

Parameters
t_StartStart of the memory block to use for this free list
t_EndEnd of the memory block to use for this free list
t_ElmSizeSize of an "element" that this list will be used for
t_NumElmsNumber of elements to store inside this free list
t_AlignmentAlignment of the element (default = 8)
t_OffsetOffset of the element (default = 0)

Member Function Documentation

◆ Obtain()

void * Fling::FreeList::Obtain ( )
inlinenoexcept

Obtain a chunk of memory of the size and alignment that this list was created with.

Returns
void* nullptr if no memory available

◆ Return()

void Fling::FreeList::Return ( void *  t_Ptr)
inline

Return a block of memory to the free list.

Memory can be returned in any order

Field Documentation

◆ m_Next

FreeList* Fling::FreeList::m_Next = nullptr
private

Alias in memory to the next available block.

Nullptr if none are available


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