Gaia-ECS v0.9.3
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::mem::detail::SmallBlockAllocatorImpl Class Referencefinal

General-purpose allocator for small, variable-sized allocations up to 512 bytes. More...

#include <smallblock_allocator.h>

Public Member Functions

 SmallBlockAllocatorImpl (SmallBlockAllocatorImpl &&)=delete
 
 SmallBlockAllocatorImpl (const SmallBlockAllocatorImpl &)=delete
 
SmallBlockAllocatorImploperator= (SmallBlockAllocatorImpl &&)=delete
 
SmallBlockAllocatorImploperator= (const SmallBlockAllocatorImpl &)=delete
 
GAIA_NODISCARD void * alloc (uint32_t bytesWanted)
 Allocates storage for up to 512 bytes.
 
void free (void *pBlock)
 Releases storage allocated for the given pointer.
 
void flush (bool releaseAll=false)
 Flushes unused pages.
 
GAIA_NODISCARD SmallBlockAllocatorStats stats () const
 Returns allocator statistics per size class.
 
void diag () const
 Performs diagnostics of allocator memory usage.
 
void verify () const
 Verifies allocator invariants.
 

Static Public Attributes

static constexpr uint32_t MAX_SIZE = SmallBlockMaxSize
 

Detailed Description

General-purpose allocator for small, variable-sized allocations up to 512 bytes.

Member Function Documentation

◆ alloc()

GAIA_NODISCARD void * gaia::mem::detail::SmallBlockAllocatorImpl::alloc ( uint32_t  bytesWanted)
inline

Allocates storage for up to 512 bytes.

Parameters
bytesWantedRequested usable bytes.
Returns
Pointer to aligned usable storage.

◆ flush()

void gaia::mem::detail::SmallBlockAllocatorImpl::flush ( bool  releaseAll = false)
inline

Flushes unused pages.

Parameters
releaseAllWhen true, all empty pages are released.

◆ free()

void gaia::mem::detail::SmallBlockAllocatorImpl::free ( void *  pBlock)
inline

Releases storage allocated for the given pointer.

Parameters
pBlockPointer previously returned by alloc().

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