Add CStdMemAlloc::GetSize() to SDK

Returns the size of the buffer allocated with MemAllocSingleton()->Alloc() etc.
This commit is contained in:
Kawe Mazidjatari 2022-08-04 02:02:09 +02:00
parent 20d1fabd0c
commit babbcbe6d5
2 changed files with 7 additions and 2 deletions

View File

@ -22,6 +22,12 @@ public:
const int index = 5;
CallVFunc<void>(index, this, pMem);
}
template<typename T>
size_t GetSize(T* pMem)
{
const int index = 6;
return CallVFunc<size_t>(index, this, pMem);
}
};
//-----------------------------------------------------------------------------

View File

@ -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
}