From b000c1e18b2af68024b6f851543c232a072c244f Mon Sep 17 00:00:00 2001 From: Charlotte Delenk Date: Thu, 21 Oct 2021 16:56:44 +0200 Subject: [PATCH] Recover some dead-stripped code --- donut/mem/Memory.cpp | 6 ++++++ donut/mem/OperatorNewDelete.cpp | 23 +++++++++++++++++++++++ include/mem/Memory.hpp | 2 ++ include/mem/OperatorNewDelete.hpp | 1 + 4 files changed, 32 insertions(+) diff --git a/donut/mem/Memory.cpp b/donut/mem/Memory.cpp index 0b1d3a23..d41ee116 100644 --- a/donut/mem/Memory.cpp +++ b/donut/mem/Memory.cpp @@ -57,6 +57,12 @@ Memory::Memory() Memory::~Memory() { object_ = 0; } +void Memory::sendArenaInfoToTerminal() { + // There is probably debug mode code in here, but in the retail game, this + // function would have been 4 bytes in size before being dead-stripped, likely + // a single blr instruction. +} + HeapExp &Memory::mem1FixHeap() { return mem1Fix_; } USED HeapExp &Memory::sceneHeap() { return scene_; } HeapExp &Memory::mem2FixHeap() { return mem2Fix_; } diff --git a/donut/mem/OperatorNewDelete.cpp b/donut/mem/OperatorNewDelete.cpp index 0ffd739c..f7ff1d7f 100644 --- a/donut/mem/OperatorNewDelete.cpp +++ b/donut/mem/OperatorNewDelete.cpp @@ -50,22 +50,45 @@ USED void *operator new(u32 size, IAllocator &alloc) { return t_operatorNew(size, alloc); } +void *operator new(u32 size, const std::nothrow_t &, IAllocator &alloc) { + return t_operatorNew(size, alloc); +} + void *operator new[](u32 size, IAllocator &alloc) { return t_operatorNew(size, alloc); } void *operator new(u32 size) { return t_operatorNew(size); } +void *operator new(u32 size, const std::nothrow_t &) { + return t_operatorNew(size); +} + void *operator new[](u32 size) { return t_operatorNew(size); } +void *operator new[](u32 size, const std::nothrow_t &) { + return t_operatorNew(size); +} + void operator delete(void *ptr) { t_operatorDelete(ptr); } +void operator delete(void *ptr, const std::nothrow_t &) { + t_operatorDelete(ptr); +} + void operator delete[](void *ptr) { t_operatorDelete(ptr); } +void operator delete[](void *ptr, const std::nothrow_t &) { + t_operatorDelete(ptr); +} + namespace mem { USED void OperatorNewDelete::SetDefaultAllocator(IAllocator &alloc) { t_allocator.ptr_ = &alloc; } +IAllocator &OperatorNewDelete::GetDefaultAllocator() { + return *t_allocator.ptr_; +} USED void OperatorNewDelete::SetGlobalNewDeleteAllocator(IAllocator &alloc) { t_globalNewDeleteAllocator.ptr_ = &alloc; } diff --git a/include/mem/Memory.hpp b/include/mem/Memory.hpp index 7f77d901..97f6d435 100644 --- a/include/mem/Memory.hpp +++ b/include/mem/Memory.hpp @@ -20,6 +20,8 @@ struct Memory : hel::common::ExplicitSingleton { Memory(); ~Memory(); + void sendArenaInfoToTerminal(); + HeapExp &mem1FixHeap(); HeapExp &sceneHeap(); HeapExp &mem2FixHeap(); diff --git a/include/mem/OperatorNewDelete.hpp b/include/mem/OperatorNewDelete.hpp index 2efad687..5379949e 100644 --- a/include/mem/OperatorNewDelete.hpp +++ b/include/mem/OperatorNewDelete.hpp @@ -5,6 +5,7 @@ namespace mem { struct OperatorNewDelete { static void SetDefaultAllocator(IAllocator &alloc); + static IAllocator &GetDefaultAllocator(void); static void SetGlobalNewDeleteAllocator(IAllocator &alloc); static void UnsetGlobalNewDeleteAllocator(IAllocator &alloc); };