ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
Buffer Struct Reference

Description:

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

Definition at line 63 of file monoallocator.hpp.

#include <monoallocator.hpp>

Collaboration diagram for Buffer:
[legend]

Public Static Field Index:

static constexpr unsigned char CLEAR = 0xF1
 
static constexpr unsigned char MAGIC = 0xA1
 

Public Static Method Index:

static constexpr size_t firstOffset (size_t firstObject, size_t alignment)
 

Public Field Index:

char * act
 Pointer to the next free space in the buffer.
 
char * end
 Pointer to the first byte behind the buffer.
 
Bufferprevious
 the previously allocated buffer.
 

Public Method Index:

 Buffer ()=default
 Defaulted default constructor.
 
ALIB_FORCE_INLINE Buffer (size_t size)
 
ALIB_FORCE_INLINE char * allocate (size_t size, size_t alignment)
 
void reset ()
 
size_t Size ()
 

Field Details:

◆ act

char* act

Pointer to the next free space in the buffer.

Definition at line 74 of file monoallocator.hpp.

◆ CLEAR

unsigned char CLEAR = 0xF1
staticconstexpr

A magic byte written when memory is freed.

See also
Field CLEAR.

Definition at line 72 of file monoallocator.hpp.

◆ end

char* end

Pointer to the first byte behind the buffer.

Definition at line 75 of file monoallocator.hpp.

◆ MAGIC

unsigned char MAGIC = 0xA1
staticconstexpr

A magic byte, used with compiler-symbol ALIB_DEBUG_ALLOCATIONS to mark memory and detect out-of-bounds writes.

See also
Method Allocator::dbgCheckMemory.

Definition at line 68 of file monoallocator.hpp.

◆ previous

Buffer* previous

the previously allocated buffer.

Definition at line 76 of file monoallocator.hpp.

Constructor(s) / Destructor Details:

◆ Buffer()

ALIB_FORCE_INLINE Buffer ( size_t size)
inline

Initializes the members of this buffer to reflect the given size.

Parameters
sizeThe size of the given mem.

Definition at line 92 of file monoallocator.hpp.

Method Details:

◆ allocate()

ALIB_FORCE_INLINE char * allocate ( size_t size,
size_t alignment )
inline

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

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

Definition at line 131 of file monoallocator.hpp.

Here is the call graph for this function:

◆ firstOffset()

static constexpr size_t firstOffset ( size_t firstObject,
size_t alignment )
inlinestaticconstexpr

Returns the first offset of an object with given alignment behind an object with. smaller alignment.

Parameters
firstObjectThe allocation size of the first object allocated in a buffer.
alignmentThe allocation alignment of the first object allocated in a buffer.
Returns
The value to add to the allocation size to ensure that an object with a certain alignment fits after placing firstObject at the start..

Definition at line 84 of file monoallocator.hpp.

◆ reset()

void reset ( )
inline

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

Definition at line 112 of file monoallocator.hpp.

◆ Size()

size_t Size ( )
inline
Returns
The size of this buffer.

Definition at line 106 of file monoallocator.hpp.


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