Stack allocator capable of instantiating any default-constructible object on stack. Every allocation comes with a 16-bytes long sentinel object.
More...
#include <stack_allocator.h>
|
|
| StackAllocator (const StackAllocator &)=delete |
| |
|
| StackAllocator (StackAllocator &&)=delete |
| |
|
StackAllocator & | operator= (const StackAllocator &)=delete |
| |
|
StackAllocator & | operator= (StackAllocator &&)=delete |
| |
| template<typename T > |
| GAIA_NODISCARD T * | alloc (uint32_t cnt) |
| | Allocates objects inside the buffer. No default initialization is done so the object is returned in a non-initialized state unless a custom constructor is provided.
|
| |
| void | free (void *pData, uint32_t cnt) |
| | Frees the last allocated object from the stack.
|
| |
|
void | reset () |
| | Frees all allocated objects from the buffer.
|
| |
| GAIA_NODISCARD constexpr uint32_t | capacity () |
| | Returns the fixed buffer capacity.
|
| |
template<uint32_t CapacityInBytes = 1024>
class gaia::mem::StackAllocator< CapacityInBytes >
Stack allocator capable of instantiating any default-constructible object on stack. Every allocation comes with a 16-bytes long sentinel object.
- Template Parameters
-
| CapacityInBytes | Size of the inline allocation buffer in bytes. |
◆ alloc()
template<uint32_t CapacityInBytes = 1024>
template<typename T >
Allocates objects inside the buffer. No default initialization is done so the object is returned in a non-initialized state unless a custom constructor is provided.
- Template Parameters
-
- Parameters
-
| cnt | Number of objects to allocate. |
- Returns
- Pointer to the first allocated object
◆ capacity()
template<uint32_t CapacityInBytes = 1024>
Returns the fixed buffer capacity.
- Returns
- Capacity in bytes.
◆ free()
template<uint32_t CapacityInBytes = 1024>
Frees the last allocated object from the stack.
- Parameters
-
| pData | Pointer to the last allocated object on the stack |
| cnt | Number of objects that were allocated on the given memory address |
The documentation for this class was generated from the following file: