[Scummvm-cvs-logs] SF.net SVN: scummvm: [25732] scummvm/trunk/common
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Mon Feb 19 22:11:13 CET 2007
Revision: 25732
http://scummvm.svn.sourceforge.net/scummvm/?rev=25732&view=rev
Author: fingolfin
Date: 2007-02-19 13:11:13 -0800 (Mon, 19 Feb 2007)
Log Message:
-----------
Enhance (Seekable)SubReadStream so be able to (optionally) dispose the parent stream after it's been used (simplifies memory management for client code)
Modified Paths:
--------------
scummvm/trunk/common/stream.cpp
scummvm/trunk/common/stream.h
Modified: scummvm/trunk/common/stream.cpp
===================================================================
--- scummvm/trunk/common/stream.cpp 2007-02-19 21:09:23 UTC (rev 25731)
+++ scummvm/trunk/common/stream.cpp 2007-02-19 21:11:13 UTC (rev 25732)
@@ -128,8 +128,8 @@
return dataSize;
}
-SeekableSubReadStream::SeekableSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end)
- : SubReadStream(parentStream, end),
+SeekableSubReadStream::SeekableSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end, bool disposeParentStream)
+ : SubReadStream(parentStream, end, disposeParentStream),
_parentStream(parentStream),
_begin(begin) {
assert(_begin <= _end);
Modified: scummvm/trunk/common/stream.h
===================================================================
--- scummvm/trunk/common/stream.h 2007-02-19 21:09:23 UTC (rev 25731)
+++ scummvm/trunk/common/stream.h 2007-02-19 21:11:13 UTC (rev 25732)
@@ -245,9 +245,16 @@
ReadStream *_parentStream;
uint32 _pos;
uint32 _end;
+ bool _disposeParentStream;
public:
- SubReadStream(ReadStream *parentStream, uint32 end)
- : _parentStream(parentStream), _pos(0), _end(end) {}
+ SubReadStream(ReadStream *parentStream, uint32 end, bool disposeParentStream = false)
+ : _parentStream(parentStream),
+ _pos(0),
+ _end(end),
+ _disposeParentStream(disposeParentStream) {}
+ ~SubReadStream() {
+ if (_disposeParentStream) delete _parentStream;
+ }
virtual bool eos() const { return _pos == _end; }
virtual uint32 read(void *dataPtr, uint32 dataSize);
@@ -263,7 +270,7 @@
SeekableReadStream *_parentStream;
uint32 _begin;
public:
- SeekableSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end);
+ SeekableSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end, bool disposeParentStream = false);
virtual uint32 pos() const { return _pos - _begin; }
virtual uint32 size() const { return _end - _begin; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list