aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorTorbjörn Andersson2010-01-03 19:37:43 +0000
committerTorbjörn Andersson2010-01-03 19:37:43 +0000
commit72eb9ec9eab5efcb3aa99a962a80423e8c0a3232 (patch)
tree032c9107838aefca6a166465a46fa7318bb82566 /engines/sci
parent910ffb53a0b6c74a965df9a1270cdfc3885252ec (diff)
downloadscummvm-rg350-72eb9ec9eab5efcb3aa99a962a80423e8c0a3232.tar.gz
scummvm-rg350-72eb9ec9eab5efcb3aa99a962a80423e8c0a3232.tar.bz2
scummvm-rg350-72eb9ec9eab5efcb3aa99a962a80423e8c0a3232.zip
Fixed a bunch of cppcheck warnings. Mostly about checking if a pointer is null
before freeing it, which isn't necessary. svn-id: r46941
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/gfx/gfx_resource.cpp6
-rw-r--r--engines/sci/gui/gui_animate.cpp12
-rw-r--r--engines/sci/gui/gui_text.cpp8
-rw-r--r--engines/sci/gui32/res_pal.cpp1
-rw-r--r--engines/sci/sfx/music.cpp3
-rw-r--r--engines/sci/sfx/softseq/adlib.cpp4
6 files changed, 11 insertions, 23 deletions
diff --git a/engines/sci/gfx/gfx_resource.cpp b/engines/sci/gfx/gfx_resource.cpp
index fe2373e4e2..4a39b0d385 100644
--- a/engines/sci/gfx/gfx_resource.cpp
+++ b/engines/sci/gfx/gfx_resource.cpp
@@ -66,11 +66,9 @@ void gfxr_free_pic(gfxr_pic_t *pic) {
pic->visual_map = NULL;
pic->priority_map = NULL;
pic->control_map = NULL;
- if (pic->priorityTable)
- free(pic->priorityTable);
+ free(pic->priorityTable);
pic->priorityTable = NULL;
- if (pic->undithered_buffer)
- free(pic->undithered_buffer);
+ free(pic->undithered_buffer);
pic->undithered_buffer = 0;
free(pic);
}
diff --git a/engines/sci/gui/gui_animate.cpp b/engines/sci/gui/gui_animate.cpp
index f7e53fa196..16e67873aa 100644
--- a/engines/sci/gui/gui_animate.cpp
+++ b/engines/sci/gui/gui_animate.cpp
@@ -44,10 +44,8 @@ SciGuiAnimate::SciGuiAnimate(EngineState *state, SciGuiGfx *gfx, SciGuiScreen *s
}
SciGuiAnimate::~SciGuiAnimate() {
- if (_listData)
- free(_listData);
- if (_lastCastData)
- free(_lastCastData);
+ free(_listData);
+ free(_lastCastData);
}
void SciGuiAnimate::init() {
@@ -129,15 +127,13 @@ void SciGuiAnimate::makeSortedList(List *list) {
// Adjust list size, if needed
if ((_listData == NULL) || (_listCount < listCount)) {
- if (_listData)
- free(_listData);
+ free(_listData);
_listData = (GuiAnimateEntry *)malloc(listCount * sizeof(GuiAnimateEntry));
if (!_listData)
error("Could not allocate memory for _listData");
_listCount = listCount;
- if (_lastCastData)
- free(_lastCastData);
+ free(_lastCastData);
_lastCastData = (GuiAnimateEntry *)malloc(listCount * sizeof(GuiAnimateEntry));
if (!_lastCastData)
error("Could not allocate memory for _lastCastData");
diff --git a/engines/sci/gui/gui_text.cpp b/engines/sci/gui/gui_text.cpp
index 21e92f9617..218008a95e 100644
--- a/engines/sci/gui/gui_text.cpp
+++ b/engines/sci/gui/gui_text.cpp
@@ -74,9 +74,7 @@ void SciGuiText::SetFont(GuiResourceId fontId) {
void SciGuiText::CodeSetFonts(int argc, reg_t *argv) {
int i;
- if (_codeFonts) {
- delete _codeFonts;
- }
+ delete _codeFonts;
_codeFontsCount = argc;
_codeFonts = new GuiResourceId[argc];
for (i = 0; i < argc; i++) {
@@ -87,9 +85,7 @@ void SciGuiText::CodeSetFonts(int argc, reg_t *argv) {
void SciGuiText::CodeSetColors(int argc, reg_t *argv) {
int i;
- if (_codeColors) {
- delete _codeColors;
- }
+ delete _codeColors;
_codeColorsCount = argc;
_codeColors = new uint16[argc];
for (i = 0; i < argc; i++) {
diff --git a/engines/sci/gui32/res_pal.cpp b/engines/sci/gui32/res_pal.cpp
index a4319afcd6..38a0eb5b60 100644
--- a/engines/sci/gui32/res_pal.cpp
+++ b/engines/sci/gui32/res_pal.cpp
@@ -125,6 +125,7 @@ Palette *gfxr_read_pal1_amiga(Common::File &file) {
b2 = file.readByte();
if (b1 == EOF || b2 == EOF) {
+ delete retval;
error("Amiga palette file ends prematurely");
return NULL;
}
diff --git a/engines/sci/sfx/music.cpp b/engines/sci/sfx/music.cpp
index 92b83d97f2..1b0f00f41f 100644
--- a/engines/sci/sfx/music.cpp
+++ b/engines/sci/sfx/music.cpp
@@ -332,8 +332,7 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
// play digital sample
if (track->digitalChannelNr != -1) {
byte *channelData = track->channels[track->digitalChannelNr].data;
- if (pSnd->pStreamAud)
- delete pSnd->pStreamAud;
+ delete pSnd->pStreamAud;
pSnd->pStreamAud = Audio::makeLinearInputStream(channelData, track->digitalSampleSize, track->digitalSampleRate,
Audio::Mixer::FLAG_UNSIGNED, 0, 0);
pSnd->soundType = Audio::Mixer::kSFXSoundType;
diff --git a/engines/sci/sfx/softseq/adlib.cpp b/engines/sci/sfx/softseq/adlib.cpp
index 1ecf22c925..e2af0a0767 100644
--- a/engines/sci/sfx/softseq/adlib.cpp
+++ b/engines/sci/sfx/softseq/adlib.cpp
@@ -238,9 +238,7 @@ void MidiDriver_Adlib::close() {
_mixer->stopHandle(_mixerSoundHandle);
delete _opl;
-
- if (_rhythmKeyMap)
- delete[] _rhythmKeyMap;
+ delete[] _rhythmKeyMap;
}
void MidiDriver_Adlib::setVolume(byte volume) {