Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::StackAllocator< T > Class Template Reference

Stack-based allocator for objects of type T. More...

#include <StackAllocator.h>

Public Member Functions

 StackAllocator (usize size)
 Constructs the allocator with capacity for given elements.
 ~StackAllocator ()
 Destructor. Releases the allocated memory block.
T * Allocate (usize count)
 Allocates space for count objects of type T.
void Reset ()
 Resets the allocator, making all memory available again.

Detailed Description

template<typename T>
class Raven::StackAllocator< T >

Stack-based allocator for objects of type T.

Allocates a fixed block of memory for T objects and provides fast bump-pointer allocation. Does not support individual deallocation; use Reset() to clear all allocations.

Template Parameters
TThe element type to allocate.

Constructor & Destructor Documentation

◆ StackAllocator()

template<typename T>
Raven::StackAllocator< T >::StackAllocator ( usize size)
inlineexplicit

Constructs the allocator with capacity for given elements.

Parameters
sizeNumber of T elements the allocator can hold.

◆ ~StackAllocator()

template<typename T>
Raven::StackAllocator< T >::~StackAllocator ( )
inline

Destructor. Releases the allocated memory block.

Member Function Documentation

◆ Allocate()

template<typename T>
T * Raven::StackAllocator< T >::Allocate ( usize count)
inline

Allocates space for count objects of type T.

Aligns the returned pointer to alignof(T). If insufficient space remains, returns nullptr.

Parameters
countNumber of T objects to allocate.
Returns
Pointer to the first allocated object, or nullptr on failure.

◆ Reset()

template<typename T>
void Raven::StackAllocator< T >::Reset ( )
inline

Resets the allocator, making all memory available again.


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