From 3fbbff133c470d05bfeeafd7b23a1a359fbf1b23 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 2 Dec 2015 12:05:44 -1000 Subject: [PATCH] CMemory falls back to malloc if uninitialized --- Runtime/CMemory.cpp | 18 ++++++++++++++++++ hecl | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Runtime/CMemory.cpp b/Runtime/CMemory.cpp index 0750bd9f6..cda74750c 100644 --- a/Runtime/CMemory.cpp +++ b/Runtime/CMemory.cpp @@ -73,6 +73,8 @@ IAllocator& CMemorySys::GetGameAllocator() {return g_gameAllocator;} void* operator new(std::size_t sz) { + if (!Retro::g_memoryAllocatorReady) + return malloc(sz); Retro::CCallStack cs("?\?(?\?)", "UnknownType"); return Retro::CMemory::Alloc(sz, Retro::IAllocator::EHint::None, @@ -84,6 +86,8 @@ void* operator new(std::size_t sz) void* operator new(std::size_t sz, const char* funcName, const char* typeName) { + if (!Retro::g_memoryAllocatorReady) + return malloc(sz); Retro::CCallStack cs(funcName, typeName); return Retro::CMemory::Alloc(sz, Retro::IAllocator::EHint::None, @@ -94,11 +98,18 @@ void* operator new(std::size_t sz, void operator delete(void* ptr) noexcept { + if (!Retro::g_memoryAllocatorReady) + { + free(ptr); + return; + } Retro::CMemory::Free(ptr); } void* operator new[](std::size_t sz) { + if (!Retro::g_memoryAllocatorReady) + return malloc(sz); Retro::CCallStack cs("?\?(?\?)", "UnknownType"); return Retro::CMemory::Alloc(sz, Retro::IAllocator::EHint::None, @@ -110,6 +121,8 @@ void* operator new[](std::size_t sz) void* operator new[](std::size_t sz, const char* funcName, const char* typeName) { + if (!Retro::g_memoryAllocatorReady) + return malloc(sz); Retro::CCallStack cs(funcName, typeName); return Retro::CMemory::Alloc(sz, Retro::IAllocator::EHint::None, @@ -120,5 +133,10 @@ void* operator new[](std::size_t sz, void operator delete[](void* ptr) noexcept { + if (!Retro::g_memoryAllocatorReady) + { + free(ptr); + return; + } Retro::CMemory::Free(ptr); } diff --git a/hecl b/hecl index e98d0f25d..1cb02347a 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit e98d0f25d94acca5675f96fe03cbb536d126faec +Subproject commit 1cb02347a52ba2d785d05c12bedbdcee3030ecbb