diff options
author | Matthew Hoops | 2011-03-07 16:37:12 -0500 |
---|---|---|
committer | Matthew Hoops | 2011-03-07 16:37:12 -0500 |
commit | 4e7b66b1bc948f9fc22ba3ce67f76f8dfe2f5f99 (patch) | |
tree | e6c0ba5d37dd9845144e6ecf2458407f7d5fa106 /graphics/wincursor.cpp | |
parent | b158a4084463d478ba961434f88971ae2a7aeac2 (diff) | |
download | scummvm-rg350-4e7b66b1bc948f9fc22ba3ce67f76f8dfe2f5f99.tar.gz scummvm-rg350-4e7b66b1bc948f9fc22ba3ce67f76f8dfe2f5f99.tar.bz2 scummvm-rg350-4e7b66b1bc948f9fc22ba3ce67f76f8dfe2f5f99.zip |
GRAPHICS: Cleanup WinCursorGroup functions a bit
ScopedPtr is now used on the streams to avoid having repetitive delete calls.
Diffstat (limited to 'graphics/wincursor.cpp')
-rw-r--r-- | graphics/wincursor.cpp | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/graphics/wincursor.cpp b/graphics/wincursor.cpp index 15ae69e2f1..d3c9414e03 100644 --- a/graphics/wincursor.cpp +++ b/graphics/wincursor.cpp @@ -26,6 +26,7 @@ #include "common/debug.h" #include "common/file.h" #include "common/memstream.h" +#include "common/ptr.h" #include "common/str.h" #include "common/stream.h" #include "common/winexe_ne.h" @@ -208,7 +209,7 @@ WinCursorGroup::~WinCursorGroup() { } WinCursorGroup *WinCursorGroup::createCursorGroup(Common::NEResources &exe, const Common::WinResourceID &id) { - Common::SeekableReadStream *stream = exe.getResource(Common::kNEGroupCursor, id); + Common::ScopedPtr<Common::SeekableReadStream> stream(exe.getResource(Common::kNEGroupCursor, id)); if (!stream || stream->size() <= 6) return 0; @@ -227,7 +228,6 @@ WinCursorGroup *WinCursorGroup::createCursorGroup(Common::NEResources &exe, cons // Plane count if (stream->readUint16LE() != 1) { - delete stream; delete group; return 0; } @@ -235,7 +235,6 @@ WinCursorGroup *WinCursorGroup::createCursorGroup(Common::NEResources &exe, cons // Bits per pixel // NE cursors can only be 1bpp if (stream->readUint16LE() != 1) { - delete stream; delete group; return 0; } @@ -243,36 +242,30 @@ WinCursorGroup *WinCursorGroup::createCursorGroup(Common::NEResources &exe, cons stream->readUint32LE(); // data size uint32 cursorId = stream->readUint32LE(); - Common::SeekableReadStream *cursorStream = exe.getResource(Common::kNECursor, cursorId); + Common::ScopedPtr<Common::SeekableReadStream> cursorStream(exe.getResource(Common::kNECursor, cursorId)); if (!cursorStream) { - delete stream; delete group; return 0; } WinCursor *cursor = new WinCursor(); if (!cursor->readFromStream(*cursorStream)) { - delete stream; - delete cursorStream; delete cursor; delete group; return 0; } - delete cursorStream; - CursorItem item; item.id = cursorId; item.cursor = cursor; group->cursors.push_back(item); } - delete stream; return group; } WinCursorGroup *WinCursorGroup::createCursorGroup(Common::PEResources &exe, const Common::WinResourceID &id) { - Common::SeekableReadStream *stream = exe.getResource(Common::kPEGroupCursor, id); + Common::ScopedPtr<Common::SeekableReadStream> stream(exe.getResource(Common::kPEGroupCursor, id)); if (!stream || stream->size() <= 6) return 0; @@ -291,7 +284,6 @@ WinCursorGroup *WinCursorGroup::createCursorGroup(Common::PEResources &exe, cons // Plane count if (stream->readUint16LE() != 1) { - delete stream; delete group; return 0; } @@ -300,31 +292,25 @@ WinCursorGroup *WinCursorGroup::createCursorGroup(Common::PEResources &exe, cons stream->readUint32LE(); // data size uint32 cursorId = stream->readUint16LE(); - Common::SeekableReadStream *cursorStream = exe.getResource(Common::kPECursor, cursorId); + Common::ScopedPtr<Common::SeekableReadStream> cursorStream(exe.getResource(Common::kPECursor, cursorId)); if (!cursorStream) { - delete stream; delete group; return 0; } WinCursor *cursor = new WinCursor(); if (!cursor->readFromStream(*cursorStream)) { - delete stream; - delete cursorStream; delete cursor; delete group; return 0; } - delete cursorStream; - CursorItem item; item.id = cursorId; item.cursor = cursor; group->cursors.push_back(item); } - delete stream; return group; } |