ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::monomem::detail::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 25 of file monoallocator.inl.

Collaboration diagram for alib::monomem::detail::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.
 
 Buffer (size_t size)
 
char * allocate (size_t size, size_t alignment)
 
void reset ()
 
size_t Size ()
 

Field Details:

◆ act

char* alib::monomem::detail::Buffer::act

Pointer to the next free space in the buffer.

Definition at line 36 of file monoallocator.inl.

◆ CLEAR

unsigned char alib::monomem::detail::Buffer::CLEAR = 0xF1
staticconstexpr

A magic byte written when memory is freed.

See also
Field CLEAR.

Definition at line 34 of file monoallocator.inl.

◆ end

char* alib::monomem::detail::Buffer::end

Pointer to the first byte behind the buffer.

Definition at line 37 of file monoallocator.inl.

◆ MAGIC

unsigned char alib::monomem::detail::Buffer::MAGIC = 0xA1
staticconstexpr

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

See also
Method Allocator::dbgCheckMemory.

Definition at line 30 of file monoallocator.inl.

◆ previous

Buffer* alib::monomem::detail::Buffer::previous

the previously allocated buffer.

Definition at line 38 of file monoallocator.inl.

Constructor(s) / Destructor Details:

◆ Buffer()

alib::monomem::detail::Buffer::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 53 of file monoallocator.inl.

Method Details:

◆ allocate()

char * alib::monomem::detail::Buffer::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 87 of file monoallocator.inl.

Here is the call graph for this function:

◆ firstOffset()

constexpr size_t alib::monomem::detail::Buffer::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 46 of file monoallocator.inl.

◆ reset()

void alib::monomem::detail::Buffer::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 71 of file monoallocator.inl.

◆ Size()

size_t alib::monomem::detail::Buffer::Size ( )
inline
Returns
The size of this buffer.

Definition at line 65 of file monoallocator.inl.


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