mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Properly fix the aligned memalloc singleton in the SDK; the implementation now uses a callback based approach for calling the allocator and deallocator.
29 lines
963 B
C++
29 lines
963 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 ((void* (*)(size_t, size_t))m_pAllocCallback)(nSize, nAlignment);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: free aligned memory
|
|
// Input : pMem -
|
|
//-----------------------------------------------------------------------------
|
|
void CAlignedMemAlloc::Free(void* pMem)
|
|
{
|
|
((void (*)(void*))m_pFreeCallback)(pMem);
|
|
}
|
|
|
|
CAlignedMemAlloc* g_pAlignedMemAlloc;
|