From babbcbe6d52e6e05c6d2904ca0e4d5f1f9e68239 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 4 Aug 2022 02:02:09 +0200 Subject: [PATCH] Add CStdMemAlloc::GetSize() to SDK Returns the size of the buffer allocated with MemAllocSingleton()->Alloc() etc. --- r5dev/tier0/memstd.h | 6 ++++++ r5dev/tier1/utlmemory.h | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/r5dev/tier0/memstd.h b/r5dev/tier0/memstd.h index 749d6c31..a7f30194 100644 --- a/r5dev/tier0/memstd.h +++ b/r5dev/tier0/memstd.h @@ -22,6 +22,12 @@ public: const int index = 5; CallVFunc(index, this, pMem); } + template + size_t GetSize(T* pMem) + { + const int index = 6; + return CallVFunc(index, this, pMem); + } }; //----------------------------------------------------------------------------- diff --git a/r5dev/tier1/utlmemory.h b/r5dev/tier1/utlmemory.h index 79a7681a..f79e8356 100644 --- a/r5dev/tier1/utlmemory.h +++ b/r5dev/tier1/utlmemory.h @@ -331,8 +331,7 @@ public: #ifdef REMEMBER_ALLOC_SIZE_FOR_VALGRIND return m_nCurAllocSize; #else - //return (m_pMemory) ? MemAllocSingleton()->GetSize(m_pMemory) : 0; // FIXME: reverse vftable and get 'GetSize' - return 0; + return (m_pMemory) ? MemAllocSingleton()->GetSize(m_pMemory) : 0; #endif }