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

Description:

Provides debugging utility methods used by allocator types HeapAllocator, TMonoAllocator, and TPoolAllocator. Each method is empty and thus optimized out in case compiler symbol ALIB_DEBUG_ALLOCATIONS is not set.

See also
Chapter 11.4 Debugging of the Programmer's Manual.

Definition at line 27 of file allocation.hpp.

#include <allocation.hpp>

Public Static Method Index:

template<class T >
static constexpr void annotate (T *mem, size_t size, unsigned char magic)
 
template<typename TSize >
static void checkMem (void *mem, const TSize size, unsigned char magic, const char *name)
 
template<class T >
static constexpr void clearMem (T *mem, size_t size, unsigned char magic)
 
template<class TIntegral >
static constexpr size_t extSize (TIntegral size)
 

Method Details:

◆ annotate()

template<class T >
static constexpr void annotate ( T * mem,
size_t size,
unsigned char magic )
inlinestaticconstexpr

Writes magic bytes and size-information behind the given memory.

Template Parameters
TThe type of the given pointer mem. (Deduced by the compiler, templated for convenience.)
Parameters
memThe pointer to the allocated object.
sizeThe originally requested size.
magicThe magic byte to write after the element.

Definition at line 51 of file allocation.hpp.

◆ checkMem()

template<typename TSize >
static void checkMem ( void * mem,
const TSize size,
unsigned char magic,
const char * name )
inlinestatic

Raises an ALib assertion if the piece of allocated memory is corrupted or its allocation size is not rightfully given by the using code.

Template Parameters
TSizeThe type of parameter size. (Deduced by the compiler.)
Parameters
memThe address of the allocated object.
sizeThe requested allocation size of the object.
magicThe value of the magic bytes that had been written with annotate.
nameThe type of the allocator. In case of type MonoAllocator, the debug-name of the instance.

Definition at line 98 of file allocation.hpp.

◆ clearMem()

template<class T >
static constexpr void clearMem ( T * mem,
size_t size,
unsigned char magic )
inlinestaticconstexpr

The given character c is written into the allocated memory (including its extended size).

Template Parameters
TThe type of the given pointer mem. (Deduced by the compiler.)
Parameters
memThe pointer to the allocated object.
sizeThe allocated size from the user's perspective (not the real size)
magicThe magic byte to overwrite the freed memory with.

Definition at line 77 of file allocation.hpp.

Here is the call graph for this function:

◆ extSize()

template<class TIntegral >
static constexpr size_t extSize ( TIntegral size)
inlinestaticconstexpr

Adds needed space for 4 magic bytes plus the size_t value that is stored.

Template Parameters
TIntegralThe type of given size. (Deduced by the compiler, templated for convenience.)
Parameters
sizeThe given size or the extended size.
Returns
The truly allocated size.

Definition at line 35 of file allocation.hpp.


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