mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Crash occurred as the arguments to the alloc/free callbacks would involve the 'this' pointer, and therefore, the registers would shift and misalign. The fix is to just make the functions static and call the pointers directly from the singleton exposed by the engine. Additional cleanup has been performed by adding typedefs for the function pointers.
29 lines
955 B
C++
29 lines
955 B
C++
//=============================================================================//
|
|
//
|
|
// Purpose:
|
|
//
|
|
//=============================================================================//
|
|
#include "tier0/tslist.h"
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: alloc aligned memory
|
|
// Input : nSize -
|
|
// nPad -
|
|
// Output : pointer to allocated aligned memory
|
|
//-----------------------------------------------------------------------------
|
|
void* CAlignedMemAlloc::Alloc(size_t nSize, size_t nAlignment)
|
|
{
|
|
return g_pAlignedMemAlloc->m_pAllocCallback(nSize, nAlignment);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: free aligned memory
|
|
// Input : pMem -
|
|
//-----------------------------------------------------------------------------
|
|
void CAlignedMemAlloc::Free(void* pMem)
|
|
{
|
|
g_pAlignedMemAlloc->m_pFreeCallback(pMem);
|
|
}
|
|
|
|
CAlignedMemAlloc* g_pAlignedMemAlloc;
|