aboutsummaryrefslogtreecommitdiff
path: root/engines/lastexpress/game
diff options
context:
space:
mode:
authorJulien Templier2010-11-11 14:19:44 +0000
committerJulien Templier2010-11-11 14:19:44 +0000
commit521f228ceddda2cfc0ed1006682d1b7dfbca7302 (patch)
treea2e217595367a0441480eff679b21edcfaa5368e /engines/lastexpress/game
parent7207d920bc2f4e01a653e0fada30698c870b9e8b (diff)
downloadscummvm-rg350-521f228ceddda2cfc0ed1006682d1b7dfbca7302.tar.gz
scummvm-rg350-521f228ceddda2cfc0ed1006682d1b7dfbca7302.tar.bz2
scummvm-rg350-521f228ceddda2cfc0ed1006682d1b7dfbca7302.zip
LASTEXPRESS: Use SAFE_DELETE for class variables
svn-id: r54201
Diffstat (limited to 'engines/lastexpress/game')
-rw-r--r--engines/lastexpress/game/action.cpp4
-rw-r--r--engines/lastexpress/game/beetle.h7
-rw-r--r--engines/lastexpress/game/entities.cpp6
-rw-r--r--engines/lastexpress/game/fight.cpp9
-rw-r--r--engines/lastexpress/game/logic.cpp12
-rw-r--r--engines/lastexpress/game/menu.cpp16
-rw-r--r--engines/lastexpress/game/scenes.cpp7
-rw-r--r--engines/lastexpress/game/sound.cpp8
-rw-r--r--engines/lastexpress/game/sound.h7
-rw-r--r--engines/lastexpress/game/state.cpp10
10 files changed, 50 insertions, 36 deletions
diff --git a/engines/lastexpress/game/action.cpp b/engines/lastexpress/game/action.cpp
index 8058d22f05..d14e295cb3 100644
--- a/engines/lastexpress/game/action.cpp
+++ b/engines/lastexpress/game/action.cpp
@@ -383,7 +383,9 @@ Action::Action(LastExpressEngine *engine) : _engine(engine) {
Action::~Action() {
for (int i = 0; i < (int)_actions.size(); i++)
- delete _actions[i];
+ SAFE_DELETE(_actions[i]);
+
+ _actions.clear();
// Zero-out passed pointers
_engine = NULL;
diff --git a/engines/lastexpress/game/beetle.h b/engines/lastexpress/game/beetle.h
index 3341e92270..661618a251 100644
--- a/engines/lastexpress/game/beetle.h
+++ b/engines/lastexpress/game/beetle.h
@@ -28,6 +28,8 @@
#include "lastexpress/data/sequence.h"
+#include "lastexpress/helpers.h"
+
#include "common/array.h"
#include "common/system.h"
@@ -98,8 +100,9 @@ private:
~BeetleData() {
for (int i = 0; i < (int)sequences.size(); i++)
- if (sequences[i])
- delete sequences[i];
+ SAFE_DELETE(sequences[i]);
+
+ sequences.clear();
}
};
diff --git a/engines/lastexpress/game/entities.cpp b/engines/lastexpress/game/entities.cpp
index adba0f1b4c..8741a4873b 100644
--- a/engines/lastexpress/game/entities.cpp
+++ b/engines/lastexpress/game/entities.cpp
@@ -185,10 +185,12 @@ Entities::Entities(LastExpressEngine *engine) : _engine(engine) {
}
Entities::~Entities() {
- delete _header;
+ SAFE_DELETE(_header);
for (int i = 0; i < (int)_entities.size(); i++)
- delete _entities[i];
+ SAFE_DELETE(_entities[i]);
+
+ _entities.clear();
// Zero passed pointers
_engine = NULL;
diff --git a/engines/lastexpress/game/fight.cpp b/engines/lastexpress/game/fight.cpp
index 8fa711df1c..9f92320575 100644
--- a/engines/lastexpress/game/fight.cpp
+++ b/engines/lastexpress/game/fight.cpp
@@ -325,11 +325,10 @@ void Fight::clearData() {
clearSequences(_data->player);
clearSequences(_data->opponent);
- delete _data->player;
- delete _data->opponent;
+ SAFE_DELETE(_data->player);
+ SAFE_DELETE(_data->opponent);
- delete _data;
- _data = NULL;
+ SAFE_DELETE(_data);
_engine->restoreEventHandlers();
}
@@ -343,7 +342,7 @@ void Fight::clearSequences(Fighter *combatant) const {
// Free sequences
for (int i = 0; i < (int)combatant->sequences.size(); i++)
- delete combatant->sequences[i];
+ SAFE_DELETE(combatant->sequences[i]);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/lastexpress/game/logic.cpp b/engines/lastexpress/game/logic.cpp
index 3ef710a324..8e7f688235 100644
--- a/engines/lastexpress/game/logic.cpp
+++ b/engines/lastexpress/game/logic.cpp
@@ -72,12 +72,12 @@ Logic::Logic(LastExpressEngine *engine) : _engine(engine) {
}
Logic::~Logic() {
- delete _action;
- delete _beetle;
- delete _fight;
- delete _entities;
- delete _saveload;
- delete _state;
+ SAFE_DELETE(_action);
+ SAFE_DELETE(_beetle);
+ SAFE_DELETE(_fight);
+ SAFE_DELETE(_entities);
+ SAFE_DELETE(_saveload);
+ SAFE_DELETE(_state);
// Zero-out passed pointers
_engine = NULL;
diff --git a/engines/lastexpress/game/menu.cpp b/engines/lastexpress/game/menu.cpp
index 6ca4f22177..9e38d05444 100644
--- a/engines/lastexpress/game/menu.cpp
+++ b/engines/lastexpress/game/menu.cpp
@@ -204,10 +204,10 @@ Clock::Clock(LastExpressEngine *engine) : _engine(engine), _frameMinutes(NULL),
}
Clock::~Clock() {
- delete _frameMinutes;
- delete _frameHour;
- delete _frameSun;
- delete _frameDate;
+ SAFE_DELETE(_frameMinutes);
+ SAFE_DELETE(_frameHour);
+ SAFE_DELETE(_frameSun);
+ SAFE_DELETE(_frameDate);
// Zero passed pointers
_engine = NULL;
@@ -291,8 +291,8 @@ TrainLine::TrainLine(LastExpressEngine *engine) : _engine(engine), _frameLine1(N
}
TrainLine::~TrainLine() {
- delete _frameLine1;
- delete _frameLine2;
+ SAFE_DELETE(_frameLine1);
+ SAFE_DELETE(_frameLine2);
// Zero passed pointers
_engine = NULL;
@@ -369,8 +369,8 @@ Menu::Menu(LastExpressEngine *engine) : _engine(engine),
}
Menu::~Menu() {
- delete _clock;
- delete _trainLine;
+ SAFE_DELETE(_clock);
+ SAFE_DELETE(_trainLine);
SAFE_DELETE(_seqTooltips);
SAFE_DELETE(_seqEggButtons);
diff --git a/engines/lastexpress/game/scenes.cpp b/engines/lastexpress/game/scenes.cpp
index 3f9aa0b3b3..15fe0617d8 100644
--- a/engines/lastexpress/game/scenes.cpp
+++ b/engines/lastexpress/game/scenes.cpp
@@ -51,8 +51,6 @@ SceneManager::SceneManager(LastExpressEngine *engine) : _engine(engine),
}
SceneManager::~SceneManager() {
- delete _sceneLoader;
-
// Clear frames
for (Common::List<SequenceFrame *>::iterator door = _doors.begin(); door != _doors.end(); ++door)
SAFE_DELETE(*door);
@@ -63,8 +61,9 @@ SceneManager::~SceneManager() {
SAFE_DELETE(_clockMinutes);
// Clear frame queue
- for (Common::List<SequenceFrame *>::iterator i = _queue.begin(); i != _queue.end(); ++i)
- SAFE_DELETE(*i);
+ _queue.clear();
+
+ SAFE_DELETE(_sceneLoader);
// Zero-out passed pointers
_engine = NULL;
diff --git a/engines/lastexpress/game/sound.cpp b/engines/lastexpress/game/sound.cpp
index 2249109fe9..b28583f729 100644
--- a/engines/lastexpress/game/sound.cpp
+++ b/engines/lastexpress/game/sound.cpp
@@ -118,9 +118,12 @@ SoundManager::SoundManager(LastExpressEngine *engine) : _engine(engine), _state(
}
SoundManager::~SoundManager() {
+ for (Common::List<SoundEntry *>::iterator i = _cache.begin(); i != _cache.end(); ++i)
+ SAFE_DELETE(*i);
+
_cache.clear();
- delete _soundStream;
+ SAFE_DELETE(_soundStream);
// Zero passed pointers
_engine = NULL;
@@ -134,6 +137,7 @@ void SoundManager::handleTimer() {
for (Common::List<SoundEntry *>::iterator i = _cache.begin(); i != _cache.end(); ++i) {
SoundEntry *entry = (*i);
if (entry->stream == NULL) {
+ SAFE_DELETE(*i);
i = _cache.reverse_erase(i);
continue;
} else if (!entry->isStreamed) {
@@ -191,7 +195,7 @@ void SoundManager::clearQueue() {
// Delete entry
removeEntry(entry);
- delete entry;
+ SAFE_DELETE(entry);
i = _cache.reverse_erase(i);
}
diff --git a/engines/lastexpress/game/sound.h b/engines/lastexpress/game/sound.h
index cf08cd7ee8..edb6086d88 100644
--- a/engines/lastexpress/game/sound.h
+++ b/engines/lastexpress/game/sound.h
@@ -71,6 +71,8 @@
#include "lastexpress/shared.h"
+#include "lastexpress/helpers.h"
+
#include "common/list.h"
#include "common/system.h"
#include "common/serializer.h"
@@ -286,7 +288,10 @@ private:
}
~SoundEntry() {
- delete stream;
+ // Entries that have been queued would have their streamed disposed automatically
+ if (!isStreamed)
+ SAFE_DELETE(stream);
+
//delete subtitle;
}
};
diff --git a/engines/lastexpress/game/state.cpp b/engines/lastexpress/game/state.cpp
index 9586c58ceb..45cb2c58ab 100644
--- a/engines/lastexpress/game/state.cpp
+++ b/engines/lastexpress/game/state.cpp
@@ -42,11 +42,11 @@ State::State(LastExpressEngine *engine) : _engine(engine), _timer(0) {
}
State::~State() {
- delete _inventory;
- delete _objects;
- delete _savepoints;
- delete _state;
- delete _flags;
+ SAFE_DELETE(_inventory);
+ SAFE_DELETE(_objects);
+ SAFE_DELETE(_savepoints);
+ SAFE_DELETE(_state);
+ SAFE_DELETE(_flags);
// Zero passed pointers
_engine = NULL;