Browse Source

Fix MemoryOutputStream destructor after the latest changes

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.4.1
falkTX 3 years ago
parent
commit
f89484645e
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 6 additions and 3 deletions
  1. +5
    -3
      source/modules/water/streams/MemoryOutputStream.cpp
  2. +1
    -0
      source/modules/water/streams/MemoryOutputStream.h

+ 5
- 3
source/modules/water/streams/MemoryOutputStream.cpp View File

@@ -30,7 +30,8 @@ namespace water {
MemoryOutputStream::MemoryOutputStream (const size_t initialSize) MemoryOutputStream::MemoryOutputStream (const size_t initialSize)
: internalBlock(), blockToUse (internalBlock), : internalBlock(), blockToUse (internalBlock),
position (0), size (0)
position (0), size (0),
usingInternalBlock (true)
{ {
internalBlock.setSize (initialSize, false); internalBlock.setSize (initialSize, false);
} }
@@ -38,7 +39,8 @@ MemoryOutputStream::MemoryOutputStream (const size_t initialSize)
MemoryOutputStream::MemoryOutputStream (MemoryBlock& memoryBlockToWriteTo, MemoryOutputStream::MemoryOutputStream (MemoryBlock& memoryBlockToWriteTo,
const bool appendToExistingBlockContent) const bool appendToExistingBlockContent)
: internalBlock(), blockToUse (memoryBlockToWriteTo), : internalBlock(), blockToUse (memoryBlockToWriteTo),
position (0), size (0)
position (0), size (0),
usingInternalBlock (false)
{ {
if (appendToExistingBlockContent) if (appendToExistingBlockContent)
position = size = memoryBlockToWriteTo.getSize(); position = size = memoryBlockToWriteTo.getSize();
@@ -56,7 +58,7 @@ void MemoryOutputStream::flush()
void MemoryOutputStream::trimExternalBlockSize() void MemoryOutputStream::trimExternalBlockSize()
{ {
if (blockToUse != internalBlock)
if (! usingInternalBlock)
blockToUse.setSize (size, false); blockToUse.setSize (size, false);
} }


+ 1
- 0
source/modules/water/streams/MemoryOutputStream.h View File

@@ -123,6 +123,7 @@ private:
MemoryBlock internalBlock; MemoryBlock internalBlock;
MemoryBlock& blockToUse; MemoryBlock& blockToUse;
size_t position, size; size_t position, size;
bool usingInternalBlock;
void trimExternalBlockSize(); void trimExternalBlockSize();
char* prepareToWrite (size_t); char* prepareToWrite (size_t);


Loading…
Cancel
Save