[+] AuNewClassArrayUnique
[+] AuNewClassArray [+] AuNewClassUnique [+] AuNewClass [*] Unfuck/refactor GetDefaultDiscontiguousHeap
This commit is contained in:
parent
c111dee855
commit
39ba32df3c
@ -164,7 +164,7 @@ namespace Aurora::Memory
|
||||
pPtr = pThat->FAlloc<AuUInt8 *>(sizeof(T) + kAlignment, kAlignment);
|
||||
if (pPtr)
|
||||
{
|
||||
new (pPtr + kAlignment) T(AuForward<Args &&>(args)...);
|
||||
new (pPtr + kAlignment) T(AuForward<Args>(args)...);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -204,7 +204,7 @@ namespace Aurora::Memory
|
||||
pPtr = pThat->FAlloc<AuUInt8 *>(sizeof(T) + kAlignment, kAlignment);
|
||||
if (pPtr)
|
||||
{
|
||||
new (pPtr + kAlignment) T(AuForward<Args &&>(args)...);
|
||||
new (pPtr + kAlignment) T(AuForward<Args>(args)...);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -248,7 +248,7 @@ namespace Aurora::Memory
|
||||
{
|
||||
for (AU_ITERATE_N(i, uElements))
|
||||
{
|
||||
new (pPtr + kAlignment + (sizeof(T) * i)) T(AuForward<Args &&>(fillCtr)...);
|
||||
new (pPtr + kAlignment + (sizeof(T) * i)) T(AuForward<Args>(fillCtr)...);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -262,7 +262,7 @@ namespace Aurora::Memory
|
||||
static_assert(false);
|
||||
#else
|
||||
auto pElements = (T *)(pPtr + kAlignment);
|
||||
std::fill(pElements, pElements + uElements, AuForward<Args &&>(fillCtr)...);
|
||||
std::fill(pElements, pElements + uElements, AuForward<Args>(fillCtr)...);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -309,7 +309,7 @@ namespace Aurora::Memory
|
||||
{
|
||||
for (AU_ITERATE_N(i, uElements))
|
||||
{
|
||||
new (pPtr + kAlignment + (sizeof(T) * i)) T(AuForward<Args &&>(fillCtr)...);
|
||||
new (pPtr + kAlignment + (sizeof(T) * i)) T(AuForward<Args>(fillCtr)...);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -323,7 +323,7 @@ namespace Aurora::Memory
|
||||
static_assert(false);
|
||||
#else
|
||||
auto pElements = (T *)(pPtr + kAlignment);
|
||||
std::fill(pElements, pElements + uElements, AuForward<Args &&>(fillCtr)...);
|
||||
std::fill(pElements, pElements + uElements, AuForward<Args>(fillCtr)...);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -409,7 +409,18 @@ namespace Aurora::Memory
|
||||
/**
|
||||
Returns a heap interface backed by the default allocator
|
||||
*/
|
||||
AUKN_SHARED_API(GetDefaultDiscontiguousHeap, Heap);
|
||||
AUKN_SHARED_API(DefaultDiscontiguousHeap, Heap);
|
||||
|
||||
inline Heap *GetDefaultDiscontiguousHeap()
|
||||
{
|
||||
return DefaultDiscontiguousHeapNew();
|
||||
}
|
||||
|
||||
inline AuSPtr<Heap> GetDefaultDiscontiguousHeapShared()
|
||||
{
|
||||
// Might not allocate the control block under some STLs, unlike DefaultDiscontiguousHeapSharedShared() which will generally always allocate a control block under most STLs
|
||||
return AuUnsafeRaiiToShared(GetDefaultDiscontiguousHeap());
|
||||
}
|
||||
|
||||
/**
|
||||
Allocates uLength amount of contiguous virtual memory
|
||||
|
@ -121,7 +121,37 @@ template <typename T>
|
||||
using AuHUPOf_t = typename Aurora::Memory::Heap::HUPOf_t<T>;
|
||||
|
||||
template <class T>
|
||||
static inline auto AuNullHeapPointer()
|
||||
auto AuNullHeapPointer()
|
||||
{
|
||||
return Aurora::Memory::Heap::NullUniquePointer<T>();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
auto AuNullPointer()
|
||||
{
|
||||
return Aurora::Memory::Heap::NullUniquePointer<T>();
|
||||
}
|
||||
|
||||
template <class T, class ...Args>
|
||||
AuHUPOf_t<T> AuNewClassArrayUnique(AuUInt uElements, Args &&... fillCtr)
|
||||
{
|
||||
return Aurora::Memory::GetDefaultDiscontiguousHeap()->NewClassArrayUnique<T, Args...>(uElements, AuForward<Args>(fillCtr)...);
|
||||
}
|
||||
|
||||
template <class T, class ...Args>
|
||||
AuSPtr<T> AuNewClassArray(AuUInt uElements, Args &&... fillCtr)
|
||||
{
|
||||
return Aurora::Memory::GetDefaultDiscontiguousHeap()->NewClassArray<T, Args...>(uElements, AuForward<Args>(fillCtr)...);
|
||||
}
|
||||
|
||||
template <class T, class ...Args>
|
||||
AuHUPOf_t<T> AuNewClassUnique(Args &&...args)
|
||||
{
|
||||
return Aurora::Memory::GetDefaultDiscontiguousHeap()->NewClassUnique<T, Args...>(AuForward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <class T, class ...Args>
|
||||
AuSPtr<T> AuNewClass(Args &&...args)
|
||||
{
|
||||
return Aurora::Memory::GetDefaultDiscontiguousHeap()->NewClass<T, Args...>(AuForward<Args>(args)...);
|
||||
}
|
@ -18,8 +18,6 @@ namespace Aurora::IO::Net
|
||||
|
||||
IPAddress NetAdapter::GetAddress()
|
||||
{
|
||||
AuMemory::GetDefaultDiscontiguousHeapShared()->NewClass<NetAdapter>();
|
||||
|
||||
return this->address;
|
||||
}
|
||||
|
||||
|
@ -97,10 +97,10 @@ namespace Aurora::Memory
|
||||
|
||||
static DefaultHeap gDefaultAllocation;
|
||||
|
||||
AUKN_SYM Heap *GetDefaultDiscontiguousHeapNew()
|
||||
AUKN_SYM Heap *DefaultDiscontiguousHeapNew()
|
||||
{
|
||||
return &gDefaultAllocation;
|
||||
}
|
||||
|
||||
AUKN_SYM void GetDefaultDiscontiguousHeapRelease(Heap * heap) {}
|
||||
AUKN_SYM void DefaultDiscontiguousHeapRelease(Heap * heap) {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user