Core memory management class that handles all memory allocations and deallocations. More...
#include <TMemory.h>
Classes | |
struct | HALMemInfo |
Hardware abstraction layer memory information. More... | |
struct | MemBlock |
Represents a contiguous block of memory that can be allocated from. More... | |
struct | MemBlockFooter |
Footer structure at the end of each memory block for validation. More... | |
struct | MemBlockSlot |
Slot for tracking memory blocks in the block list. More... | |
struct | MemInfo |
Structure containing memory usage statistics. More... | |
class | MemNode |
Represents a node in the memory allocation system. More... | |
Public Member Functions | |
TMemory () | |
Constructor for TMemory class Initializes the memory management system. | |
~TMemory () | |
Destructor for TMemory class Cleans up the memory management system. | |
void * | Alloc (TSIZE a_uiSize, TSIZE a_uiAlignment, MemBlock *a_pMemBlock, const TCHAR *a_szFileName, TINT a_iLineNum) |
Allocates memory with specified size and alignment. | |
TBOOL | Free (const void *a_pMem) |
Frees previously allocated memory. | |
void * | SysAlloc (TSIZE a_uiSize) |
Allocates memory from the system heap. | |
void | SysFree (void *a_pMem) |
Frees memory back to the system heap. | |
MemBlock * | CreateMemBlock (TSIZE a_uiSize, const TCHAR *a_szName, MemBlock *a_pOwnerBlock, TINT a_iUnused) |
Creates a new memory block. | |
MemBlock * | CreateMemBlockInPlace (void *a_pMem, TSIZE a_uiSize, const TCHAR *a_szName) |
Creates a memory block at a specific location. | |
void | DestroyMemBlock (MemBlock *a_pMemBlock) |
Destroys a memory block. | |
MemBlock * | GetGlobalBlock () const |
Gets the global memory block. | |
TMemory::MemBlock * | SetGlobalBlock (MemBlock *a_pMemBlock) |
Sets the global memory block. | |
TUINT | GetGlobalFlags () const |
void | DumpMemInfo () |
Static Public Member Functions | |
static void | GetMemInfo (MemInfo &a_rMemInfo, MemBlock *a_pMemBlock) |
static void | GetHALMemInfo (HALMemInfo &a_rHALMemInfo) |
static TBOOL | Initialise (TSIZE a_uiHeapSize, TSIZE a_uiReservedSize, TUINT a_uiUnused=0) |
Initializes the memory system. | |
static void | Deinitialise () |
Deinitializes the memory system. | |
static TUINT | MapSizeToFreeList (TSIZE a_uiSize) |
static void | DebugPrintHALMemInfo (const TCHAR *a_szFormat,...) |
Debug print of HAL memory info. | |
Core memory management class that handles all memory allocations and deallocations.
This class implements a custom memory allocator with the following features:
TMemory::TMemory | ( | ) |
Constructor for TMemory class Initializes the memory management system.
Constructor for TMemory class Initializes the memory management system and sets up the global instance.
Definition at line 138 of file TMemory.cpp.
TMemory::~TMemory | ( | ) |
void * TMemory::Alloc | ( | TSIZE | a_uiSize, |
TSIZE | a_uiAlignment, | ||
MemBlock * | a_pMemBlock, | ||
const TCHAR * | a_szFileName, | ||
TINT | a_iLineNum ) |
Allocates memory with specified size and alignment.
a_uiSize | Size of memory to allocate |
a_uiAlignment | Alignment requirement for the allocation |
a_pMemBlock | Memory block to allocate from (NULL for global block) |
a_szFileName | Source file name for debugging |
a_iLineNum | Source line number for debugging |
a_uiSize | Size of memory to allocate |
a_uiAlignment | Alignment requirement for the allocation |
a_pMemBlock | Memory block to allocate from (NULL for global block) |
a_szFileName | Source file name for debugging |
a_iLineNum | Source line number for debugging |
This function implements the core memory allocation logic:
Definition at line 213 of file TMemory.cpp.
TMemory::MemBlock * TMemory::CreateMemBlock | ( | TSIZE | a_uiSize, |
const TCHAR * | a_szName, | ||
MemBlock * | a_pOwnerBlock, | ||
TINT | a_iUnused ) |
Creates a new memory block.
a_uiSize | Size of the memory block |
a_szName | Name of the memory block |
a_pOwnerBlock | Owner block (NULL for global block) |
a_iUnused | Unused parameter |
a_uiSize | Size of the memory block |
a_szName | Name of the memory block |
a_pOwnerBlock | Owner block (NULL for global block) |
a_iUnused | Unused parameter |
This function:
Definition at line 488 of file TMemory.cpp.
TMemory::MemBlock * TMemory::CreateMemBlockInPlace | ( | void * | a_pMem, |
TSIZE | a_uiSize, | ||
const TCHAR * | a_szName ) |
Creates a memory block at a specific location.
a_pMem | Pointer to memory location |
a_uiSize | Size of the memory block |
a_szName | Name of the memory block |
a_pMem | Pointer to memory location |
a_uiSize | Size of the memory block |
a_szName | Name of the memory block |
This function:
Definition at line 508 of file TMemory.cpp.
|
static |
Debug print of HAL memory info.
a_szFormat | Format string |
... | Variable arguments |
Definition at line 845 of file TMemory.cpp.
|
static |
Deinitializes the memory system.
This function:
Definition at line 743 of file TMemory.cpp.
void TMemory::DestroyMemBlock | ( | MemBlock * | a_pMemBlock | ) |
Destroys a memory block.
a_pMemBlock | Pointer to memory block to destroy |
a_pMemBlock | Pointer to memory block to destroy |
This function:
Definition at line 572 of file TMemory.cpp.
void TMemory::DumpMemInfo | ( | ) |
Definition at line 809 of file TMemory.cpp.
TBOOL TMemory::Free | ( | const void * | a_pAllocated | ) |
Frees previously allocated memory.
a_pMem | Pointer to memory to free |
a_pAllocated | Pointer to memory to free |
This function implements the core memory deallocation logic:
Definition at line 399 of file TMemory.cpp.
Toshi::TMemory::MemBlock * TMemory::GetGlobalBlock | ( | ) | const |
Gets the global memory block.
Definition at line 582 of file TMemory.cpp.
|
inline |
|
static |
Definition at line 956 of file TMemory.cpp.
Definition at line 864 of file TMemory.cpp.
|
static |
Initializes the memory system.
a_uiHeapSize | Size of the heap |
a_uiReservedSize | Size of reserved memory |
a_uiUnused | Unused parameter |
This function:
Definition at line 708 of file TMemory.cpp.
Definition at line 767 of file TMemory.cpp.
TMemory::MemBlock * TMemory::SetGlobalBlock | ( | MemBlock * | a_pMemBlock | ) |
Sets the global memory block.
a_pMemBlock | New global memory block |
Definition at line 793 of file TMemory.cpp.
void * TMemory::SysAlloc | ( | TSIZE | a_uiSize | ) |
Allocates memory from the system heap.
a_uiSize | Size of memory to allocate |
Definition at line 13 of file TMemory_Win.cpp.
void TMemory::SysFree | ( | void * | a_pMem | ) |
Frees memory back to the system heap.
a_pMem | Pointer to memory to free |
Definition at line 21 of file TMemory_Win.cpp.