aboutsummaryrefslogtreecommitdiff
path: root/common/stream.cpp
diff options
context:
space:
mode:
authorChristoph Mallon2011-08-06 16:30:52 +0200
committerChristoph Mallon2011-08-07 15:19:08 +0200
commita5a8833c059f28c85e392a3cd22c361d38ef95ff (patch)
tree3b3b69326019444c2c375c66f39cb3013a003591 /common/stream.cpp
parent2f23ff72c1d804d9d0e3ac09c46f52fd6b23a68c (diff)
downloadscummvm-rg350-a5a8833c059f28c85e392a3cd22c361d38ef95ff.tar.gz
scummvm-rg350-a5a8833c059f28c85e392a3cd22c361d38ef95ff.tar.bz2
scummvm-rg350-a5a8833c059f28c85e392a3cd22c361d38ef95ff.zip
COMMON: Add DisposablePtr<T>, which replaces many repeated implementations of a dispose flag.
Diffstat (limited to 'common/stream.cpp')
-rw-r--r--common/stream.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/common/stream.cpp b/common/stream.cpp
index 60b40d0df2..30b3bca497 100644
--- a/common/stream.cpp
+++ b/common/stream.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "common/ptr.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "common/substream.h"
@@ -258,8 +259,7 @@ namespace {
*/
class BufferedReadStream : virtual public ReadStream {
protected:
- ReadStream *_parentStream;
- DisposeAfterUse::Flag _disposeParentStream;
+ DisposablePtr<ReadStream> _parentStream;
byte *_buf;
uint32 _pos;
bool _eos; // end of stream
@@ -278,8 +278,7 @@ public:
};
BufferedReadStream::BufferedReadStream(ReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream)
- : _parentStream(parentStream),
- _disposeParentStream(disposeParentStream),
+ : _parentStream(parentStream, disposeParentStream),
_pos(0),
_eos(false),
_bufSize(0),
@@ -291,8 +290,6 @@ BufferedReadStream::BufferedReadStream(ReadStream *parentStream, uint32 bufSize,
}
BufferedReadStream::~BufferedReadStream() {
- if (_disposeParentStream)
- delete _parentStream;
delete[] _buf;
}