[+] ByteBuffer::SetBuffer(MemoryViewRead readView)

[*] revert 6317a563
This commit is contained in:
Reece Wilson 2023-04-29 14:04:31 +01:00
parent c3a986495c
commit e0d672ae9b
2 changed files with 18 additions and 8 deletions

View File

@ -281,14 +281,7 @@ namespace Aurora::Memory
this->flagReadError = 0;
this->flagWriteError = 0;
this->readPtr = base;
if (this->flagCircular)
{
this->writePtr = base;
}
else
{
this->writePtr = this->base + length;
}
this->writePtr = base;
}
// utils: Iterator
@ -395,6 +388,7 @@ namespace Aurora::Memory
inline auline bool Allocate(AuUInt length, bool fast = true);
inline auline bool Allocate(AuUInt length, AuUInt alignment, bool fast = true);
inline auline bool SetBuffer(MemoryViewRead readView);
inline auline bool SetBuffer(const void *in, AuUInt length);
inline auline bool SetBuffer(const AuList<AuUInt8> &buffer);

View File

@ -68,6 +68,22 @@ namespace Aurora::Memory
return true;
}
bool ByteBuffer::SetBuffer(MemoryViewRead readView)
{
if (!Allocate(readView.length))
{
return false;
}
if (!this->length)
{
return true;
}
AuMemcpy(this->base, readView.ptr, this->length);
return true;
}
bool ByteBuffer::SetBuffer(const void *in, AuUInt length)
{
if (!Allocate(length))