ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
MonoAllocator::Chunk Struct Reference

Description:


Internal type defining an allocated chunk of memory. The allocation space is found behind this object itself as it is placed at the start of each allocated chunk.

Definition at line 93 of file monoallocator.hpp.

#include <monoallocator.hpp>

Collaboration diagram for MonoAllocator::Chunk:
[legend]

Public Static Method Index:

static ALIB_FORCE_INLINE Chunkcreate (size_t size)
 

Public Field Index:

char * act
 Pointer to the free space in the chunk.
 
char * end
 Pointer to the first byte behind the chunk.
 
Chunkprevious
 the previously allocated chunk.
 

Public Method Index:

 Chunk ()=default
 
template<size_t requestedSize, size_t alignment>
ALIB_FORCE_INLINE char * alloc ()
 
ALIB_FORCE_INLINE char * alloc (size_t requestedSize, size_t alignment)
 
void destruct ()
 
void reset ()
 

Field Details:

◆ act

char* act

Pointer to the free space in the chunk.

Definition at line 96 of file monoallocator.hpp.

◆ end

char* end

Pointer to the first byte behind the chunk.

Definition at line 97 of file monoallocator.hpp.

◆ previous

Chunk* previous

the previously allocated chunk.

Definition at line 95 of file monoallocator.hpp.

Constructor(s) / Destructor Details::

◆ Chunk()

Chunk ( )
default

Defaulted default constructor

Method Details:

◆ alloc() [1/2]

template<size_t requestedSize, size_t alignment>
ALIB_FORCE_INLINE char * alloc ( )
inline

Templated version of alloc(size_t, size_t). Used with sizes and alignment known at compile-time.

Template Parameters
requestedSizeThe size to allocate.
alignmentThe necessary alignment.
Returns
nullptr on failure, otherwise pointer to the requested memory.

Definition at line 180 of file monoallocator.hpp.

◆ alloc() [2/2]

ALIB_FORCE_INLINE char * alloc ( size_t requestedSize,
size_t alignment )
inline

Returns a pointer to an aligned piece of memory of the requested size inside this chunk. If there is not enough space left, nullptr is returned.

Parameters
requestedSizeThe size to allocate.
alignmentThe necessary alignment.
Returns
nullptr on failure, otherwise pointer to the requested memory.

Definition at line 158 of file monoallocator.hpp.

◆ create()

static ALIB_FORCE_INLINE Chunk * create ( size_t size)
inlinestatic

Allocates a chunk of memory of a size so that an instance of this class as well as the desired minimum size minSize plus alignment bytes are all fitting in.

This memory is not freed with a destructor. Instead, the allocated chunk that objects of this type reside in has to be deleted by invoking method destruct.

Parameters
sizeThe minimum size (of the usable part) of the chunk of memory allocate, taking the maximum possible alignment space into account.
Returns
An new allocated and internally linked chunk of memory.

Definition at line 113 of file monoallocator.hpp.

Here is the call graph for this function:

◆ destruct()

void destruct ( )
inline

Deletes the allocated chunk and with it, this object itself.

Definition at line 133 of file monoallocator.hpp.

◆ reset()

void reset ( )
inline

"Frees" all allocated memory, by simply resetting the fill marker of the this chunk to the first usable byte of the allocated chunk.

Definition at line 142 of file monoallocator.hpp.


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