From f89484645e4c5340c026f0f939b553140f23fddd Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 14 Oct 2021 22:15:07 +0100 Subject: [PATCH] Fix MemoryOutputStream destructor after the latest changes Signed-off-by: falkTX --- source/modules/water/streams/MemoryOutputStream.cpp | 8 +++++--- source/modules/water/streams/MemoryOutputStream.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/modules/water/streams/MemoryOutputStream.cpp b/source/modules/water/streams/MemoryOutputStream.cpp index ac01071d3..ee1eb046e 100644 --- a/source/modules/water/streams/MemoryOutputStream.cpp +++ b/source/modules/water/streams/MemoryOutputStream.cpp @@ -30,7 +30,8 @@ namespace water { MemoryOutputStream::MemoryOutputStream (const size_t initialSize) : internalBlock(), blockToUse (internalBlock), - position (0), size (0) + position (0), size (0), + usingInternalBlock (true) { internalBlock.setSize (initialSize, false); } @@ -38,7 +39,8 @@ MemoryOutputStream::MemoryOutputStream (const size_t initialSize) MemoryOutputStream::MemoryOutputStream (MemoryBlock& memoryBlockToWriteTo, const bool appendToExistingBlockContent) : internalBlock(), blockToUse (memoryBlockToWriteTo), - position (0), size (0) + position (0), size (0), + usingInternalBlock (false) { if (appendToExistingBlockContent) position = size = memoryBlockToWriteTo.getSize(); @@ -56,7 +58,7 @@ void MemoryOutputStream::flush() void MemoryOutputStream::trimExternalBlockSize() { - if (blockToUse != internalBlock) + if (! usingInternalBlock) blockToUse.setSize (size, false); } diff --git a/source/modules/water/streams/MemoryOutputStream.h b/source/modules/water/streams/MemoryOutputStream.h index 812372fba..35369f778 100644 --- a/source/modules/water/streams/MemoryOutputStream.h +++ b/source/modules/water/streams/MemoryOutputStream.h @@ -123,6 +123,7 @@ private: MemoryBlock internalBlock; MemoryBlock& blockToUse; size_t position, size; + bool usingInternalBlock; void trimExternalBlockSize(); char* prepareToWrite (size_t);