aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/memalloc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDedicatedTest/memalloc.cpp')
-rw-r--r--NorthstarDedicatedTest/memalloc.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/NorthstarDedicatedTest/memalloc.cpp b/NorthstarDedicatedTest/memalloc.cpp
index 4ba54c73..e00d3fc7 100644
--- a/NorthstarDedicatedTest/memalloc.cpp
+++ b/NorthstarDedicatedTest/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);
}