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);