aboutsummaryrefslogtreecommitdiff
path: root/common/stream.h
diff options
context:
space:
mode:
authorMax Horn2010-11-18 16:08:56 +0000
committerMax Horn2010-11-18 16:08:56 +0000
commit4707b610fca45c0762e25994594fc58557945a02 (patch)
tree01437dc021de6452b231058d2bb7845c38534e42 /common/stream.h
parentbac018a3aa1dea0282f5ba49f9eb2001737e8bee (diff)
downloadscummvm-rg350-4707b610fca45c0762e25994594fc58557945a02.tar.gz
scummvm-rg350-4707b610fca45c0762e25994594fc58557945a02.tar.bz2
scummvm-rg350-4707b610fca45c0762e25994594fc58557945a02.zip
COMMON: Fix incorrect use of assert() macro
The assert() macro may be compiled to be empty. In that case, its arguments are *NOT* evaluated. Hence, things like assert(doSomething()) must not be used whenever doSomething() has important side effects. Also document BufferedWriteStream::flushBuffer() and explain why it exists parallel to BufferedWriteStream::flush(). svn-id: r54322
Diffstat (limited to 'common/stream.h')
-rw-r--r--common/stream.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/common/stream.h b/common/stream.h
index c6605cb42d..d497cabe2b 100644
--- a/common/stream.h
+++ b/common/stream.h
@@ -534,15 +534,23 @@ protected:
DisposeAfterUse::Flag _disposeParentStream;
byte *_buf;
uint32 _pos;
- uint32 _bufSize;
- bool flushBuffer(); // write out the data in the buffer
+ const uint32 _bufSize;
+
+ /**
+ * Write out the data in the buffer.
+ *
+ * @note This method is identical to flush() (which actually is
+ * implemented by calling this method), except that it is not
+ * virtual, hence there is less overhead calling it.
+ */
+ bool flushBuffer();
public:
BufferedWriteStream(WriteStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO);
virtual ~BufferedWriteStream();
virtual uint32 write(const void *dataPtr, uint32 dataSize);
- virtual bool flush();
+ virtual bool flush() { return flushBuffer(); }
};
/**