ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Fields | Public Static Methods | Public Methods | List of all members
MonoAllocator::Chunk Struct Reference

#include <monoallocator.hpp>

Collaboration diagram for MonoAllocator::Chunk:
[legend]

Class 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 101 of file monoallocator.hpp.

Public Fields

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 Static Methods

static ALIB_FORCE_INLINE Chunkcreate (size_t size)
 

Public Methods

 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 ()
 

Constructor & Destructor Documentation

◆ Chunk()

Chunk ( )
default

Defaulted default constructor

Member Function Documentation

◆ alloc() [1/2]

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 188 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 166 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 121 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 141 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 150 of file monoallocator.hpp.


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