[+] Heap::Clone(Heap *[, ...])
This commit is contained in:
parent
ced9e0be17
commit
8df3f6970b
@ -9,6 +9,13 @@
|
|||||||
|
|
||||||
namespace Aurora::Memory
|
namespace Aurora::Memory
|
||||||
{
|
{
|
||||||
|
struct Heap;
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
inline AuSPtr<AuUInt8> AllocateArray(Heap *pHeap, AuUInt uLength, AuUInt32 uAlignment);
|
||||||
|
}
|
||||||
|
|
||||||
struct MemoryControlBlock
|
struct MemoryControlBlock
|
||||||
{
|
{
|
||||||
// Free-after-use mitigator: ensures a non-zero flag is kept whilst other memory views are present
|
// Free-after-use mitigator: ensures a non-zero flag is kept whilst other memory views are present
|
||||||
@ -392,6 +399,19 @@ namespace Aurora::Memory
|
|||||||
return MemoryView(MemoryView(pData.get(), uLength), pData);
|
return MemoryView(MemoryView(pData.get(), uLength), pData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MemoryView Clone(Heap *pHeap, AuUInt32 uAlignment = alignof(double)) const
|
||||||
|
{
|
||||||
|
auto uLength = this->uLength;
|
||||||
|
auto pData = detail::AllocateArray(uLength, uAlignment);
|
||||||
|
if (!pData)
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
AuMemcpy(pData.get(), this->pBase, uLength);
|
||||||
|
return MemoryView(MemoryView(pData.get(), uLength), pData);
|
||||||
|
}
|
||||||
|
|
||||||
bool TryCloneSelf(bool bResetOnFailure = true)
|
bool TryCloneSelf(bool bResetOnFailure = true)
|
||||||
{
|
{
|
||||||
auto replacement = Clone();
|
auto replacement = Clone();
|
||||||
|
Loading…
Reference in New Issue
Block a user