From 94b41f5d2e75b43700902c12ba4fd0fd9426b0e8 Mon Sep 17 00:00:00 2001 From: Yotam Barnoy Date: Tue, 14 Sep 2010 14:57:30 +0000 Subject: [PATCH] COMMON: remove virtual functions from BufferedStreams As Max pointed out to me, they don't work as expected when called from constructors/destructors. svn-id: r52724 --- common/stream.cpp | 20 ++------------------ common/stream.h | 4 ---- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/common/stream.cpp b/common/stream.cpp index 718c806ff3a..8f8f278afdf 100644 --- a/common/stream.cpp +++ b/common/stream.cpp @@ -231,21 +231,13 @@ BufferedReadStream::BufferedReadStream(ReadStream *parentStream, uint32 bufSize, _realBufSize(bufSize) { assert(parentStream); - allocBuf(bufSize); - assert(_buf); -} - -void BufferedReadStream::allocBuf(uint32 bufSize) { _buf = new byte[bufSize]; + assert(_buf); } BufferedReadStream::~BufferedReadStream() { if (_disposeParentStream) delete _parentStream; - deallocBuf(); -} - -void BufferedReadStream::deallocBuf() { delete[] _buf; } @@ -334,7 +326,7 @@ BufferedWriteStream::BufferedWriteStream(WriteStream *parentStream, uint32 bufSi _bufSize(bufSize) { assert(parentStream); - allocBuf(bufSize); + _buf = new byte[bufSize]; assert(_buf); } @@ -344,14 +336,6 @@ BufferedWriteStream::~BufferedWriteStream() { if (_disposeParentStream) delete _parentStream; - deallocBuf(); -} - -void BufferedWriteStream::allocBuf(uint32 bufSize) { - _buf = new byte[bufSize]; -} - -void BufferedWriteStream::deallocBuf() { delete[] _buf; } diff --git a/common/stream.h b/common/stream.h index 10cc8c79cd1..4e627c2b1de 100644 --- a/common/stream.h +++ b/common/stream.h @@ -497,8 +497,6 @@ protected: bool _eos; // end of stream uint32 _bufSize; uint32 _realBufSize; - void allocBuf(uint32 bufSize); - void deallocBuf(); public: BufferedReadStream(ReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO); @@ -538,8 +536,6 @@ protected: uint32 _pos; uint32 _bufSize; bool flushBuffer(); // write out the data in the buffer - void allocBuf(uint32 bufSize); - void deallocBuf(); public: BufferedWriteStream(WriteStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO);