diff --git a/Include/Aurora/Memory/CppHeapWrapper.hpp b/Include/Aurora/Memory/CppHeapWrapper.hpp index a23c0206..3d6b45ed 100644 --- a/Include/Aurora/Memory/CppHeapWrapper.hpp +++ b/Include/Aurora/Memory/CppHeapWrapper.hpp @@ -141,7 +141,7 @@ namespace Aurora::Memory return this->GetHeapRaw()->Free(p); } - #if defined(AU_LANG_CPP_23) + #if defined(AU_LANG_CPP_23_) std::allocation_result allocate_at_least(const size_t count) { auto pThat = this->allocate(count); @@ -217,6 +217,15 @@ namespace Aurora::Memory this->deallocate_object(p); } + bool IsInitialized() const + { + #if defined(AU_NO_COMPRESS_CPPHEAP_WRAPPER) + return bool(this->pHeap); + #else + return bool(this->spHeap); + #endif + } + std::shared_ptr GetHeap() const { if (this->pFuckCppRetardsFixYourWorthlessSpec) @@ -235,22 +244,39 @@ namespace Aurora::Memory Heap *GetHeapRaw() const { + Heap *pRet {}; + if (this->pFuckCppRetardsFixYourWorthlessSpec) { - return this->pFuckCppRetardsFixYourWorthlessSpec->GetHeapRaw(); + pRet = this->pFuckCppRetardsFixYourWorthlessSpec->GetHeapRaw(); } else { #if defined(AU_NO_COMPRESS_CPPHEAP_WRAPPER) - return this->pHeap; + pRet = this->pHeap; #else - return this->spHeap.get(); + pRet = this->spHeap.get(); #endif } + + if (pRet) + { + return pRet; + } + + #if defined(AU_NO_COMPRESS_CPPHEAP_WRAPPER) + return this->pHeap = __audetail::gDefaultDiscontiguousHeap; + #else + return (this->spHeap = __audetail::gDefaultDiscontiguousHeapShared).get(); + #endif } void SetHeap(std::shared_ptr pHeap) { + if (this->pFuckCppRetardsFixYourWorthlessSpec) + { + return; + } if (this->pFuckCppRetardsFixYourWorthlessSpec) { this->pFuckCppRetardsFixYourWorthlessSpec->SetHeap(pHeap); @@ -266,6 +292,10 @@ namespace Aurora::Memory void SetHeapRaw(Heap *pHeap) { + if (this->pFuckCppRetardsFixYourWorthlessSpec) + { + return; + } if (this->pFuckCppRetardsFixYourWorthlessSpec) { this->pFuckCppRetardsFixYourWorthlessSpec->SetHeapRaw(pHeap); @@ -291,10 +321,10 @@ namespace Aurora::Memory // should be sizeof(void *) * 4 = [pHeap, pControlBlock, pParent, pSingleThreadChild] // nor not. it doesnt matter. #if defined(AU_NO_COMPRESS_CPPHEAP_WRAPPER) - std::shared_ptr spHeap; - Heap *pHeap {}; + mutable std::shared_ptr spHeap; + mutable Heap *pHeap {}; #else - std::shared_ptr spHeap; + mutable std::shared_ptr spHeap; #endif mutable CppHeapWrapper *pFuckCppRetardsFixYourWorthlessSpec {}; mutable CppHeapWrapper *pFuckCppRetardsFixYourWorthlessSpec2 {}; diff --git a/Include/Aurora/Memory/Memory.hpp b/Include/Aurora/Memory/Memory.hpp index 39e32e11..c98afb15 100644 --- a/Include/Aurora/Memory/Memory.hpp +++ b/Include/Aurora/Memory/Memory.hpp @@ -21,6 +21,12 @@ namespace Aurora::Memory #include "HeapStats.hpp" #include "Heap.hpp" +namespace __audetail +{ + inline auto gDefaultDiscontiguousHeap = Aurora::Memory::GetDefaultDiscontiguousHeap(); + inline auto gDefaultDiscontiguousHeapShared = Aurora::Memory::GetDefaultDiscontiguousHeapShared(); +} + #include "Cache.hpp" #include "SwapLock.hpp" #include "Transition.hpp" diff --git a/Include/Aurora/RuntimeAliases.hpp b/Include/Aurora/RuntimeAliases.hpp index 32387c99..88e20c3b 100644 --- a/Include/Aurora/RuntimeAliases.hpp +++ b/Include/Aurora/RuntimeAliases.hpp @@ -142,11 +142,6 @@ auto AuNullPointer() return Aurora::Memory::Heap::NullUniquePointer(); } -namespace __audetail -{ - inline AuMemory::Heap *gDefaultDiscontiguousHeap = AuMemory::GetDefaultDiscontiguousHeap(); -} - template AuHUPOf_t AuNewClassArrayUnique(AuUInt uElements, Args &&... fillCtr) {