void LTMemDisableStackTracking() { if(VerifyMemoryInterface()) { g_pILTMemory->DisableStackTracking(); } }
//function that allows for pushing the context data onto the stack void LTMemPopMemoryContext() { if(VerifyMemoryInterface()) { g_pILTMemory->PopMemoryContext(); } }
void LTMemExternalFree(uint32 nMemCategory, uint32 nSize, void *pMemory) { if(VerifyMemoryInterface()) { g_pILTMemory->FreeExternalAllocation(nMemCategory, nSize, pMemory); } }
void LTMemOnExit() { if(VerifyMemoryInterface()) { g_pILTMemory->OnExit(); } }
//function that allows for pushing the context data onto the stack void LTMemPushMemoryContext(const char* pszFile, uint32 nLine, uint32 nCategoryID) { if(VerifyMemoryInterface()) { g_pILTMemory->PushMemoryContext(pszFile, nLine, nCategoryID); } }
//This will provide access to the ILTMemory interface. ILTMemory* LTMemGetILTMemory() { if(VerifyMemoryInterface()) { return g_pILTMemory; } return NULL; }
void* operator new[] (size_t nSize) { if(VerifyMemoryInterface()) { return g_pILTMemory->Allocate((uint32)nSize); } //no memory interface available, just allocate the data return malloc(nSize); }
//matching delete for our tracked allocator void operator delete (void* pData, const char* pszFile, uint32 nLine, uint32 nAllocType) { if(VerifyMemoryInterface()) { g_pILTMemory->Free(pData); return; } free(pData); }
//overload operator delete void operator delete(void* pData) { if(VerifyMemoryInterface()) { g_pILTMemory->Free(pData); return; } free(pData); }
//overload operator delete void operator delete[](void* pData) { if(VerifyMemoryInterface()) { g_pILTMemory->Free(pData); return; } //no memory interface available, just allocate the data free(pData); }
//operator new that also tracks where the memory was allocated from void* operator new (size_t nSize, const char* pszFile, uint32 nLine, uint32 nAllocType) { if(VerifyMemoryInterface()) { g_pILTMemory->SetAllocInfo(pszFile, nLine, nAllocType); void* pRV = g_pILTMemory->Allocate(nSize); g_pILTMemory->ReleaseAllocInfo(); return pRV; } return malloc(nSize); }
//overload operator new void* operator new (size_t nSize) { if(VerifyMemoryInterface()) { //we have a call to new that did not go through debug new, at least filter it //into the appropriate game code section g_pILTMemory->SetAllocInfo(__FILE__, __LINE__, LT_MEM_TYPE_UNKNOWN); void* pRV = g_pILTMemory->Allocate(nSize); g_pILTMemory->ReleaseAllocInfo(); return pRV; } return malloc(nSize); }