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>
|
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) |
|
◆ 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
-
T | The type of the given pointer mem. (Deduced by the compiler, templated for convenience.) |
- Parameters
-
mem | The pointer to the allocated object. |
size | The originally requested size. |
magic | The 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
-
TSize | The type of parameter size. (Deduced by the compiler.) |
- Parameters
-
mem | The address of the allocated object. |
size | The requested allocation size of the object. |
magic | The value of the magic bytes that had been written with annotate. |
name | The 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
-
T | The type of the given pointer mem. (Deduced by the compiler.) |
- Parameters
-
mem | The pointer to the allocated object. |
size | The allocated size from the user's perspective (not the real size) |
magic | The magic byte to overwrite the freed memory with. |
Definition at line 77 of file allocation.hpp.
◆ 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
-
TIntegral | The type of given size. (Deduced by the compiler, templated for convenience.) |
- Parameters
-
size | The 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: