diff options
Diffstat (limited to 'NorthstarDLL/memalloc.cpp')
-rw-r--r-- | NorthstarDLL/memalloc.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/NorthstarDLL/memalloc.cpp b/NorthstarDLL/memalloc.cpp index e2240269..8c0fafc8 100644 --- a/NorthstarDLL/memalloc.cpp +++ b/NorthstarDLL/memalloc.cpp @@ -1,6 +1,8 @@ #include "pch.h" #include "memalloc.h" -#include "gameutils.h" +#include "tier0.h" + +using namespace Tier0; // TODO: rename to malloc and free after removing statically compiled .libs @@ -8,9 +10,8 @@ extern "C" void* _malloc_base(size_t n) { // allocate into static buffer if g_pMemAllocSingleton isn't initialised if (!g_pMemAllocSingleton) - { - InitialiseTier0GameUtilFunctions(GetModuleHandleA("tier0.dll")); - } + TryCreateGlobalMemAlloc(); + return g_pMemAllocSingleton->m_vtable->Alloc(g_pMemAllocSingleton, n); } @@ -22,19 +23,16 @@ extern "C" void* _malloc_base(size_t n) extern "C" void _free_base(void* p) { if (!g_pMemAllocSingleton) - { - spdlog::warn("Trying to free something before g_pMemAllocSingleton was ready, this should never happen"); - InitialiseTier0GameUtilFunctions(GetModuleHandleA("tier0.dll")); - } + TryCreateGlobalMemAlloc(); + g_pMemAllocSingleton->m_vtable->Free(g_pMemAllocSingleton, p); } extern "C" void* _realloc_base(void* oldPtr, size_t size) { if (!g_pMemAllocSingleton) - { - InitialiseTier0GameUtilFunctions(GetModuleHandleA("tier0.dll")); - } + TryCreateGlobalMemAlloc(); + return g_pMemAllocSingleton->m_vtable->Realloc(g_pMemAllocSingleton, oldPtr, size); } |