From daf4552eb25a488b3c1f3304370ae9f9a79ba2d6 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Tue, 9 Jul 2024 02:08:17 +0100 Subject: [PATCH] [*] Update AuByteBuffer::Pad to include bUpdateWriteHead argument. broke previous behavior bc this is more convenient and old users were already doing this after the fact --- Include/Aurora/Memory/ByteBuffer.hpp | 2 +- Include/Aurora/Memory/ByteBuffer_Utility.inl | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Include/Aurora/Memory/ByteBuffer.hpp b/Include/Aurora/Memory/ByteBuffer.hpp index 56b36378..56c04248 100644 --- a/Include/Aurora/Memory/ByteBuffer.hpp +++ b/Include/Aurora/Memory/ByteBuffer.hpp @@ -397,7 +397,7 @@ namespace Aurora::Memory // Utilities inline bool Trim(AuUInt tail); - inline bool Pad(AuUInt16 aPowOf2, AuUInt8 magicCharacter = '\x00'); + inline bool Pad(AuUInt16 aPowOf2, AuUInt8 magicCharacter = '\x00', bool bUpdateWriteHead = true); inline bool Fill(AuUInt length, AuUInt8 magicCharacter = '\x00'); // Templated read/write for **PODs** diff --git a/Include/Aurora/Memory/ByteBuffer_Utility.inl b/Include/Aurora/Memory/ByteBuffer_Utility.inl index a14cc0f6..abf0d1c8 100644 --- a/Include/Aurora/Memory/ByteBuffer_Utility.inl +++ b/Include/Aurora/Memory/ByteBuffer_Utility.inl @@ -67,7 +67,7 @@ namespace Aurora::Memory return true; } - bool ByteBuffer::Pad(AuUInt16 aPowOf2, AuUInt8 magicCharacter) + bool ByteBuffer::Pad(AuUInt16 aPowOf2, AuUInt8 magicCharacter, bool bUpdateWriteHead) { ByteBufferPushWriteState a(*this); @@ -85,7 +85,14 @@ namespace Aurora::Memory return false; } - this->writePtr = this->base + length; + if (bUpdateWriteHead) + { + this->writePtr = this->base + newLen; + } + else + { + this->writePtr = this->base + length; + } return true; } } \ No newline at end of file