mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
MemoryOutputStream: Fix preallocating overly large buffer
This commit is contained in:
parent
c51bfd7429
commit
bfe163cdad
1 changed files with 2 additions and 2 deletions
|
|
@ -172,7 +172,7 @@ bool MemoryOutputStream::setPosition (int64 newPosition)
|
|||
int64 MemoryOutputStream::writeFromInputStream (InputStream& source, int64 maxNumBytesToWrite)
|
||||
{
|
||||
// before writing from an input, see if we can preallocate to make it more efficient..
|
||||
int64 availableData = source.getTotalLength() - source.getPosition();
|
||||
const auto availableData = source.getTotalLength() - source.getPosition();
|
||||
|
||||
if (availableData > 0)
|
||||
{
|
||||
|
|
@ -180,7 +180,7 @@ int64 MemoryOutputStream::writeFromInputStream (InputStream& source, int64 maxNu
|
|||
maxNumBytesToWrite = availableData;
|
||||
|
||||
if (blockToUse != nullptr)
|
||||
preallocate (blockToUse->getSize() + (size_t) maxNumBytesToWrite);
|
||||
preallocate (position + (size_t) availableData);
|
||||
}
|
||||
|
||||
return OutputStream::writeFromInputStream (source, maxNumBytesToWrite);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue