Core memory management system for the Toshi engine. More...
#include "Toshi/TNodeList.h"
Go to the source code of this file.
Classes | |
class | TMemory |
Core memory management class that handles all memory allocations and deallocations. More... | |
class | TMemory::MemNode |
Represents a node in the memory allocation system. More... | |
struct | TMemory::MemBlock |
Represents a contiguous block of memory that can be allocated from. More... | |
struct | TMemory::MemBlockFooter |
Footer structure at the end of each memory block for validation. More... | |
struct | TMemory::MemBlockSlot |
Slot for tracking memory blocks in the block list. More... | |
struct | TMemory::MemInfo |
Structure containing memory usage statistics. More... | |
struct | TMemory::HALMemInfo |
Hardware abstraction layer memory information. More... | |
Macros | |
#define | TMEMORY_ROUNDUP 4 |
Minimum alignment for memory blocks. | |
#define | TMEMORY_FLAGS_HOLE_PROCESS 1 |
Flag indicating a memory block is in use. | |
#define | TMEMORY_FLAGS_MASK ( ( 1 << 2 ) - 1 ) |
Mask for memory block flags. | |
#define | TMEMORY_NUM_FREELISTS 9 |
Number of free list buckets for different sizes. | |
#define | TMEMORY_NUM_BLOCK_SLOTS 128 |
Maximum number of memory block slots. | |
#define | TMEMORY_ALLOC_MEMNODE_SIZE sizeof( Toshi::TMemory::MemNode ) |
Size of memory node structure. | |
#define | TMEMORY_ALLOC_RESERVED_SIZE ( TMEMORY_ALLOC_MEMNODE_SIZE - sizeof( void* ) ) |
Reserved space in allocations. | |
Functions | |
TOSHI_NAMESPACE_END void * | TMalloc (TSIZE a_uiSize) |
Allocates memory with default alignment. | |
void * | TMalloc (TSIZE a_uiSize, const TCHAR *a_szFileName, TINT a_iLineNum) |
Allocates memory with debug information. | |
void * | TMalloc (TSIZE a_uiSize, Toshi::TMemory::MemBlock *a_pMemBlock, const TCHAR *a_szFileName=TNULL, TINT a_iLineNum=-1) |
Allocates memory from a specific memory block. | |
void * | TMemalign (TSIZE a_uiSize, TSIZE a_uiAlignment) |
Allocates aligned memory. | |
void * | TMemalign (TSIZE a_uiAlignment, TSIZE a_uiSize, Toshi::TMemory::MemBlock *a_pMemBlock) |
Allocates aligned memory from a specific memory block. | |
void | TFree (void *a_pMem) |
Frees previously allocated memory. | |
template<class T, class... Args> | |
TFORCEINLINE T * | TConstruct (T *a_pMemory, Args &&... args) |
Constructs an object in place. | |
template<class T, class... Args> | |
TFORCEINLINE T * | TConstructArray (T *a_pMemory, TSIZE a_uiNumTimes, Args &&... args) |
Constructs an array of objects in place. | |
template<class T> | |
TFORCEINLINE void | TDestruct (T *a_pPtr) |
Destructs an object. | |
TFORCEINLINE void *__CRTDECL | operator new (size_t size, Toshi::TMemory::MemBlock *block) |
Placement new operator for memory blocks. | |
TFORCEINLINE void *__CRTDECL | operator new[] (size_t size, Toshi::TMemory::MemBlock *block) |
Placement new[] operator for memory blocks. | |
TFORCEINLINE void __CRTDECL | operator delete (void *ptr, Toshi::TMemory::MemBlock *block) noexcept |
Placement delete operator for memory blocks. | |
TFORCEINLINE void __CRTDECL | operator delete[] (void *ptr, Toshi::TMemory::MemBlock *block) noexcept |
Placement delete[] operator for memory blocks. | |
Variables | |
TOSHI_NAMESPACE_START class TMemory * | g_pMemory |
Core memory management system for the Toshi engine.
This file implements a custom memory allocator that provides:
Definition in file TMemory.h.
#define TMEMORY_ALLOC_MEMNODE_SIZE sizeof( Toshi::TMemory::MemNode ) |
#define TMEMORY_ALLOC_RESERVED_SIZE ( TMEMORY_ALLOC_MEMNODE_SIZE - sizeof( void* ) ) |
#define TMEMORY_FLAGS_HOLE_PROCESS 1 |
#define TMEMORY_FLAGS_MASK ( ( 1 << 2 ) - 1 ) |
#define TMEMORY_NUM_BLOCK_SLOTS 128 |
#define TMEMORY_NUM_FREELISTS 9 |
#define TMEMORY_ROUNDUP 4 |
|
noexcept |
|
noexcept |
TFORCEINLINE void *__CRTDECL operator new | ( | size_t | size, |
Toshi::TMemory::MemBlock * | block ) |
Placement new operator for memory blocks.
size | Size to allocate |
block | Memory block to allocate from |
Definition at line 476 of file TMemory.h.
TFORCEINLINE void *__CRTDECL operator new[] | ( | size_t | size, |
Toshi::TMemory::MemBlock * | block ) |
Placement new[] operator for memory blocks.
size | Size to allocate |
block | Memory block to allocate from |
TFORCEINLINE T * TConstruct | ( | T * | a_pMemory, |
Args &&... | args ) |
Constructs an object in place.
T | Type of object to construct |
Args | Types of constructor arguments |
a_pMemory | Memory location to construct in |
args | Constructor arguments |
Definition at line 431 of file TMemory.h.
TFORCEINLINE T * TConstructArray | ( | T * | a_pMemory, |
TSIZE | a_uiNumTimes, | ||
Args &&... | args ) |
Constructs an array of objects in place.
T | Type of objects to construct |
Args | Types of constructor arguments |
a_pMemory | Memory location to construct in |
a_uiNumTimes | Number of objects to construct |
args | Constructor arguments |
Definition at line 446 of file TMemory.h.
TFORCEINLINE void TDestruct | ( | T * | a_pPtr | ) |
void TFree | ( | void * | a_pMem | ) |
Frees previously allocated memory.
a_pMem | Pointer to memory to free |
Definition at line 1054 of file TMemory.cpp.
TOSHI_NAMESPACE_END void * TMalloc | ( | TSIZE | a_uiSize | ) |
Allocates memory with default alignment.
a_uiSize | Size of memory to allocate |
Definition at line 1005 of file TMemory.cpp.
Allocates memory with debug information.
a_uiSize | Size of memory to allocate |
a_szFileName | Source file name |
a_iLineNum | Source line number |
Definition at line 990 of file TMemory.cpp.
void * TMalloc | ( | TSIZE | a_uiSize, |
Toshi::TMemory::MemBlock * | a_pMemBlock, | ||
const TCHAR * | a_szFileName = TNULL, | ||
TINT | a_iLineNum = -1 ) |
Allocates memory from a specific memory block.
a_uiSize | Size of memory to allocate |
a_pMemBlock | Memory block to allocate from |
a_szFileName | Source file name (optional) |
a_iLineNum | Source line number (optional) |
Definition at line 973 of file TMemory.cpp.
Allocates aligned memory from a specific memory block.
a_uiAlignment | Alignment requirement |
a_uiSize | Size of memory to allocate |
a_pMemBlock | Memory block to allocate from |
Definition at line 1020 of file TMemory.cpp.
Allocates aligned memory.
a_uiSize | Size of memory to allocate |
a_uiAlignment | Alignment requirement |
Definition at line 1038 of file TMemory.cpp.
|
extern |