From 1337f04122cac5f0343090ac23119e4133624db0 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Tue, 14 Nov 2017 12:57:07 -0600 Subject: FULLPIPE: Fix memory leaks of SceneTag --- engines/fullpipe/objects.h | 4 ++-- engines/fullpipe/scene.cpp | 5 ++--- engines/fullpipe/stateloader.cpp | 8 +------- 3 files changed, 5 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/fullpipe/objects.h b/engines/fullpipe/objects.h index 78165c4f8d..7501f2bda7 100644 --- a/engines/fullpipe/objects.h +++ b/engines/fullpipe/objects.h @@ -23,6 +23,7 @@ #ifndef FULLPIPE_OBJECTS_H #define FULLPIPE_OBJECTS_H +#include "common/ptr.h" #include "fullpipe/utils.h" namespace Fullpipe { @@ -34,12 +35,11 @@ class GameProject : public CObject { public: int _field_4; Common::String _headerFilename; - SceneTagList *_sceneTagList; + Common::ScopedPtr _sceneTagList; int _field_10; public: GameProject(); - ~GameProject(); virtual bool load(MfcArchive &file); }; diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp index 46ad205278..6295e3b2d6 100644 --- a/engines/fullpipe/scene.cpp +++ b/engines/fullpipe/scene.cpp @@ -61,9 +61,8 @@ bool SceneTagList::load(MfcArchive &file) { int numEntries = file.readUint16LE(); for (int i = 0; i < numEntries; i++) { - SceneTag *t = new SceneTag(); - t->load(file); - push_back(*t); + push_back(SceneTag()); + back().load(file); } return true; diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp index 34c2252c79..de10f2e34c 100644 --- a/engines/fullpipe/stateloader.cpp +++ b/engines/fullpipe/stateloader.cpp @@ -359,8 +359,6 @@ bool FullpipeEngine::loadGam(const char *fname, int scene) { GameProject::GameProject() { _field_4 = 0; _field_10 = 12; - - _sceneTagList = 0; } bool GameProject::load(MfcArchive &file) { @@ -380,7 +378,7 @@ bool GameProject::load(MfcArchive &file) { debugC(1, kDebugLoading, "_scrollSpeed = %d", g_fp->_scrollSpeed); debugC(1, kDebugLoading, "_headerFilename = %s", _headerFilename.c_str()); - _sceneTagList = new SceneTagList(); + _sceneTagList.reset(new SceneTagList()); _sceneTagList->load(file); @@ -395,10 +393,6 @@ bool GameProject::load(MfcArchive &file) { return true; } -GameProject::~GameProject() { - delete _sceneTagList; -} - GameVar::GameVar() { _subVars = 0; _parentVarObj = 0; -- cgit v1.2.3