From 20e0473af11a5511635d37f54a9d4dfee3865b8d Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Fri, 19 Jan 2024 19:40:38 +0000 Subject: [PATCH] [+] AuNullHeapPointer() --- Include/Aurora/Memory/Heap.hpp | 11 ++++++++++- Include/Aurora/RuntimeAliases.hpp | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Include/Aurora/Memory/Heap.hpp b/Include/Aurora/Memory/Heap.hpp index 054921c5..dab33f20 100644 --- a/Include/Aurora/Memory/Heap.hpp +++ b/Include/Aurora/Memory/Heap.hpp @@ -181,6 +181,7 @@ namespace Aurora::Memory return AuSPtr((T *)(pPtr + kAlignment), &Heap::DeleteThat); } + // note: callers can use AuHUPOf_t pUniquePointer = AuNullHeapPointer() template AuUPtr)> NewClassUnique(Args &&...args) @@ -279,6 +280,8 @@ namespace Aurora::Memory return AuSPtr((T *)(pPtr + kAlignment), &Heap::DeleteThatArray); } + // note: callers can use AuHUPOf_t pUniquePointer = AuNullHeapPointer() + template AuUPtr)> NewClassArrayUnique(AuUInt uElements, Args &&... fillCtr) { @@ -338,6 +341,12 @@ namespace Aurora::Memory return AuUPtr)>((T *)(pPtr + kAlignment), &Heap::DeleteThatArray); } + template + cstatic AuUPtr)> NullUniquePointer() + { + return AuUPtr)>(nullptr, &Heap::RetardedSpecWrittenByRetards); + } + template static AuSPtr ToSmartPointer(AuSPtr heap, T *pHead, @@ -412,4 +421,4 @@ namespace Aurora::Memory // Proxies an existing heap with encapsulated statistics and leak detector AUKN_SHARED_API(HeapProxyEx, Heap, const AuSPtr &pHead, LeakFinderAlloc_f pfAlloc, LeakFinderFree_f pfFree); -} +} \ No newline at end of file diff --git a/Include/Aurora/RuntimeAliases.hpp b/Include/Aurora/RuntimeAliases.hpp index 7fe87a14..16fb153e 100644 --- a/Include/Aurora/RuntimeAliases.hpp +++ b/Include/Aurora/RuntimeAliases.hpp @@ -116,4 +116,10 @@ static inline void AuDebugBreak() } template -using AuHUPOf_t = typename Aurora::Memory::Heap::HUPOf_t; \ No newline at end of file +using AuHUPOf_t = typename Aurora::Memory::Heap::HUPOf_t; + +template +static inline auto AuNullHeapPointer() +{ + return Aurora::Memory::Heap::NullUniquePointer(); +} \ No newline at end of file