diff options
author | Torbjörn Andersson | 2010-01-03 19:37:43 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2010-01-03 19:37:43 +0000 |
commit | 72eb9ec9eab5efcb3aa99a962a80423e8c0a3232 (patch) | |
tree | 032c9107838aefca6a166465a46fa7318bb82566 /engines/sky | |
parent | 910ffb53a0b6c74a965df9a1270cdfc3885252ec (diff) | |
download | scummvm-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/sky')
-rw-r--r-- | engines/sky/control.cpp | 15 | ||||
-rw-r--r-- | engines/sky/detection.cpp | 2 | ||||
-rw-r--r-- | engines/sky/intro.cpp | 3 | ||||
-rw-r--r-- | engines/sky/music/musicbase.cpp | 6 | ||||
-rw-r--r-- | engines/sky/screen.cpp | 9 | ||||
-rw-r--r-- | engines/sky/sound.cpp | 6 | ||||
-rw-r--r-- | engines/sky/text.cpp | 9 |
7 files changed, 17 insertions, 33 deletions
diff --git a/engines/sky/control.cpp b/engines/sky/control.cpp index 2e17d2595f..30c616f12d 100644 --- a/engines/sky/control.cpp +++ b/engines/sky/control.cpp @@ -165,8 +165,7 @@ ControlStatus::ControlStatus(Text *skyText, OSystem *system, uint8 *scrBuf) { } ControlStatus::~ControlStatus() { - if (_textData) - free(_textData); + free(_textData); delete _statusText; } @@ -184,8 +183,7 @@ void ControlStatus::setToText(const char *newText) { } void ControlStatus::setToText(uint16 textNum) { - if (_textData) - free(_textData); + free(_textData); DisplayedText disText = _skyText->displayText(textNum, NULL, true, STATUS_WIDTH, 255); _textData = (DataFileHeader *)disText.textData; _statusText->setSprite(_textData); @@ -330,16 +328,14 @@ void Control::initPanel() { void Control::buttonControl(ConResource *pButton) { char autoSave[] = "Restore Autosave"; if (pButton == NULL) { - if (_textSprite) - free(_textSprite); + free(_textSprite); _textSprite = NULL; _curButtonText = 0; _text->setSprite(NULL); return; } if (_curButtonText != pButton->_text) { - if (_textSprite) - free(_textSprite); + free(_textSprite); _textSprite = NULL; _curButtonText = pButton->_text; if (pButton->_text) { @@ -647,8 +643,7 @@ bool Control::getYesNo(char *text) { } _mouseClicked = false; _skyMouse->spriteMouse(MOUSE_NORMAL, 0, 0); - if (dlgTextDat) - free(dlgTextDat); + free(dlgTextDat); delete dlgText; return retVal; } diff --git a/engines/sky/detection.cpp b/engines/sky/detection.cpp index 1a14703972..8feffab6e6 100644 --- a/engines/sky/detection.cpp +++ b/engines/sky/detection.cpp @@ -206,7 +206,7 @@ SaveStateList SkyMetaEngine::listSaves(const char *target) const { saveList.insert_at(0, SaveStateDescriptor(0, "*AUTOSAVE*")); // Prepare the list of savestates by looping over all matching savefiles - for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); file++) { + for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { // Extract the extension Common::String ext = file->c_str() + file->size() - 3; ext.toUppercase(); diff --git a/engines/sky/intro.cpp b/engines/sky/intro.cpp index bb715442bb..ae6e445303 100644 --- a/engines/sky/intro.cpp +++ b/engines/sky/intro.cpp @@ -743,8 +743,7 @@ bool Intro::nextPart(uint16 *&data) { return true; case LOADBG: _mixer->stopID(SOUND_BG); - if (_bgBuf) - free(_bgBuf); + free(_bgBuf); _bgBuf = _skyDisk->loadFile(*data++); _bgSize = _skyDisk->_lastLoadedFileSize; return true; diff --git a/engines/sky/music/musicbase.cpp b/engines/sky/music/musicbase.cpp index a4eeaa017d..0d3cb65e1b 100644 --- a/engines/sky/music/musicbase.cpp +++ b/engines/sky/music/musicbase.cpp @@ -40,16 +40,14 @@ MusicBase::MusicBase(Disk *pDisk) { MusicBase::~MusicBase() { stopMusic(); - if (_musicData) - free(_musicData); + free(_musicData); } void MusicBase::loadSection(uint8 pSection) { _mutex.lock(); if (_currentMusic) stopMusicInternal(); - if (_musicData) - free(_musicData); + free(_musicData); _currentSection = pSection; _musicData = _skyDisk->loadFile(_driverFileBase + FILES_PER_SECTION * pSection); diff --git a/engines/sky/screen.cpp b/engines/sky/screen.cpp index 86949eb73e..fb42da4b97 100644 --- a/engines/sky/screen.cpp +++ b/engines/sky/screen.cpp @@ -93,10 +93,8 @@ Screen::Screen(OSystem *pSystem, Disk *pDisk, SkyCompact *skyCompact) { Screen::~Screen() { free(_gameGrid); - if (_currentScreen) - free(_currentScreen); - if (_scrollScreen) - free(_scrollScreen); + free(_currentScreen); + free(_scrollScreen); } void Screen::clearScreen() { @@ -151,8 +149,7 @@ void Screen::setPalette(uint16 fileNum) { void Screen::showScreen(uint16 fileNum) { // This is only used for static images in the floppy and cd intro - if (_currentScreen) - free(_currentScreen); + free(_currentScreen); _currentScreen = _skyDisk->loadFile(fileNum); // make sure the last 8 lines are forced to black. memset(_currentScreen + GAME_SCREEN_HEIGHT * GAME_SCREEN_WIDTH, 0, (FULL_SCREEN_HEIGHT - GAME_SCREEN_HEIGHT) * GAME_SCREEN_WIDTH); diff --git a/engines/sky/sound.cpp b/engines/sky/sound.cpp index c4bfd52b64..67cb1b8fbd 100644 --- a/engines/sky/sound.cpp +++ b/engines/sky/sound.cpp @@ -1030,8 +1030,7 @@ Sound::Sound(Audio::Mixer *mixer, Disk *pDisk, uint8 pVolume) { Sound::~Sound() { _mixer->stopAll(); - if (_soundData) - free(_soundData); + free(_soundData); } void Sound::playSound(uint32 id, byte *sound, uint32 size, Audio::SoundHandle *handle) { @@ -1049,8 +1048,7 @@ void Sound::loadSection(uint8 pSection) { fnStopFx(); _mixer->stopAll(); - if (_soundData) - free(_soundData); + free(_soundData); _soundData = _skyDisk->loadFile(pSection * 4 + SOUND_FILE_BASE); uint16 asmOfs; if (SkyEngine::_systemVars.gameVersion == 109) { diff --git a/engines/sky/text.cpp b/engines/sky/text.cpp index 66e03b08bc..73c376dbbe 100644 --- a/engines/sky/text.cpp +++ b/engines/sky/text.cpp @@ -78,12 +78,9 @@ Text::~Text() { SkyEngine::_itemList[i] = NULL; } - if (_mainCharacterSet.addr) - free(_mainCharacterSet.addr); - if (_controlCharacterSet.addr) - free(_controlCharacterSet.addr); - if (_linkCharacterSet.addr) - free(_linkCharacterSet.addr); + free(_mainCharacterSet.addr); + free(_controlCharacterSet.addr); + free(_linkCharacterSet.addr); } void Text::fnSetFont(uint32 fontNr) { |