[*] Fix: AuByteBuffer::Resize could resize with wrong ringbuffer alignmnet or linear if a fast path fails
[+] ByteBuffer::ByteBuffer(const MemoryViewRead &readView, AuUInt uAlignment, bool circular, bool expandable
This commit is contained in:
parent
3241ebb349
commit
ee9e318511
@ -125,6 +125,8 @@ namespace Aurora::Memory
|
||||
|
||||
inline ByteBuffer(const MemoryViewRead &readView, bool circular = false, bool expandable = false);
|
||||
|
||||
inline ByteBuffer(const MemoryViewRead &readView, AuUInt uAlignment, bool circular = false, bool expandable = false);
|
||||
|
||||
inline ByteBuffer(const AuList<AuUInt8> &vector, bool circular = false, bool expandable = false);
|
||||
|
||||
inline ByteBuffer(AuUInt length, bool circular = false, bool expandable = false);
|
||||
|
@ -297,13 +297,12 @@ namespace Aurora::Memory
|
||||
}
|
||||
}
|
||||
|
||||
ByteBuffer replacement(length, (bool)this->flagCircular, (bool)this->flagExpandable);
|
||||
ByteBuffer replacement(length, this->alignment, (bool)this->flagCircular, (bool)this->flagExpandable);
|
||||
if (!replacement)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
replacement.flagAlwaysExpandable = this->flagAlwaysExpandable;
|
||||
replacement.alignment = this->alignment;
|
||||
|
||||
AuUInt uBytesRem {};
|
||||
if (!this->flagCircular && length < (uBytesRem = this->RemainingBytes()))
|
||||
|
@ -313,6 +313,29 @@ namespace Aurora::Memory
|
||||
AuMemcpy(this->base, vector.data(), this->length);
|
||||
}
|
||||
|
||||
ByteBuffer::ByteBuffer(const MemoryViewRead &readView, AuUInt uAlignment, bool circular, bool expandable) :
|
||||
flagCircular(circular), flagExpandable(expandable), flagReadError(0), flagWriteError(0)
|
||||
{
|
||||
this->scaleSize = kBufferInitialPower;
|
||||
if (!length)
|
||||
{
|
||||
Reset();
|
||||
return;
|
||||
}
|
||||
this->base = ZAlloc<AuUInt8 *>(length, alignment);
|
||||
this->alignment = uAlignment;
|
||||
if (!this->base)
|
||||
{
|
||||
Reset();
|
||||
return;
|
||||
}
|
||||
this->length = length;
|
||||
this->allocSize = length;
|
||||
this->readPtr = this->base;
|
||||
this->writePtr = this->readPtr + this->length;
|
||||
AuMemcpy(this->base, readView.Begin(), length);
|
||||
}
|
||||
|
||||
ByteBuffer::ByteBuffer(AuUInt length, bool circular, bool expandable) :
|
||||
flagCircular(circular), flagExpandable(expandable), flagReadError(0), flagWriteError(0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user