diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index bc7cbb819f3..c1c536f5066 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -41,7 +41,7 @@ void Keymapper::Domain::addKeymap(Keymap *map) { } void Keymapper::Domain::deleteAllKeyMaps() { - for (iterator it = begin(); it != end(); it++) + for (iterator it = begin(); it != end(); ++it) delete it->_value; clear(); diff --git a/backends/vkeybd/image-map.cpp b/backends/vkeybd/image-map.cpp index 75f467d97ed..0b18a16ee0b 100644 --- a/backends/vkeybd/image-map.cpp +++ b/backends/vkeybd/image-map.cpp @@ -53,7 +53,7 @@ void ImageMap::removeArea(const String& id) { void ImageMap::removeAllAreas() { HashMap::iterator it; - for (it = _areas.begin(); it != _areas.end(); it++) { + for (it = _areas.begin(); it != _areas.end(); ++it) { delete it->_value; } _areas.clear(); @@ -61,7 +61,7 @@ void ImageMap::removeAllAreas() { String ImageMap::findMapArea(int16 x, int16 y) { HashMap::iterator it; - for (it = _areas.begin(); it != _areas.end(); it++) { + for (it = _areas.begin(); it != _areas.end(); ++it) { if (it->_value->contains(x, y)) return it->_key; } diff --git a/backends/vkeybd/virtual-keyboard.cpp b/backends/vkeybd/virtual-keyboard.cpp index 6ddc357d20c..1367dbbda87 100644 --- a/backends/vkeybd/virtual-keyboard.cpp +++ b/backends/vkeybd/virtual-keyboard.cpp @@ -58,9 +58,9 @@ VirtualKeyboard::~VirtualKeyboard() { void VirtualKeyboard::deleteEvents() { ModeMap::iterator it_m; VKEventMap::iterator it_e; - for (it_m = _modes.begin(); it_m != _modes.end(); it_m++) { + for (it_m = _modes.begin(); it_m != _modes.end(); ++it_m) { VKEventMap *evt = &(it_m->_value.events); - for (it_e = evt->begin(); it_e != evt->end(); it_e++) + for (it_e = evt->begin(); it_e != evt->end(); ++it_e) delete it_e->_value; } } diff --git a/base/plugins.cpp b/base/plugins.cpp index 3b2a461943e..52cb601c91c 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -117,7 +117,7 @@ PluginList FilePluginProvider::getPlugins() { pluginDirs.push_back(Common::FSNode(pluginsPath)); Common::FSList::const_iterator dir; - for (dir = pluginDirs.begin(); dir != pluginDirs.end(); dir++) { + for (dir = pluginDirs.begin(); dir != pluginDirs.end(); ++dir) { // Load all plugins. // Scan for all plugins in this directory Common::FSList files; diff --git a/engines/grim/actor.cpp b/engines/grim/actor.cpp index 5a827e75bf5..25f87d2f639 100644 --- a/engines/grim/actor.cpp +++ b/engines/grim/actor.cpp @@ -489,7 +489,7 @@ void Actor::setHead(int joint1, int joint2, int joint3, float maxRoll, float max } Costume *Actor::findCostume(const char *n) { - for (Common::List::iterator i = _costumeStack.begin(); i != _costumeStack.end(); i++) + for (Common::List::iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i) if (strcasecmp((*i)->filename(), n) == 0) return *i; @@ -602,7 +602,7 @@ void Actor::update() { } } - for (Common::List::iterator i = _costumeStack.begin(); i != _costumeStack.end(); i++) { + for (Common::List::iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i) { (*i)->setPosRotate(_pos, _pitch, _yaw, _roll); (*i)->update(); } @@ -616,7 +616,7 @@ void Actor::draw() { g_winX1 = g_winY1 = 1000; g_winX2 = g_winY2 = -1000; - for (Common::List::iterator i = _costumeStack.begin(); i != _costumeStack.end(); i++) + for (Common::List::iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i) (*i)->setupTextures(); if (!g_driver->isHardwareAccelerated() && g_grim->getFlagRefreshShadowMask()) { diff --git a/engines/grim/gfx_opengl.cpp b/engines/grim/gfx_opengl.cpp index ec8dcf613bf..b93f2fe62ca 100644 --- a/engines/grim/gfx_opengl.cpp +++ b/engines/grim/gfx_opengl.cpp @@ -301,7 +301,7 @@ void GfxOpenGL::drawShadowPlanes() { glDisable(GL_LIGHTING); glDisable(GL_TEXTURE); _currentShadowArray->planeList.begin(); - for (SectorListType::iterator i = _currentShadowArray->planeList.begin(); i != _currentShadowArray->planeList.end(); i++) { + for (SectorListType::iterator i = _currentShadowArray->planeList.begin(); i != _currentShadowArray->planeList.end(); ++i) { Sector *shadowSector = *i; glBegin(GL_POLYGON); for (int k = 0; k < shadowSector->getNumVertices(); k++) { diff --git a/engines/grim/gfx_tinygl.cpp b/engines/grim/gfx_tinygl.cpp index 3f94a1c43fa..d7044b14b72 100644 --- a/engines/grim/gfx_tinygl.cpp +++ b/engines/grim/gfx_tinygl.cpp @@ -405,7 +405,7 @@ void GfxTinyGL::drawShadowPlanes() { tglSetShadowMaskBuf(_currentShadowArray->shadowMask); _currentShadowArray->planeList.begin(); - for (SectorListType::iterator i = _currentShadowArray->planeList.begin(); i != _currentShadowArray->planeList.end(); i++) { + for (SectorListType::iterator i = _currentShadowArray->planeList.begin(); i != _currentShadowArray->planeList.end(); ++i) { Sector *shadowSector = *i; tglBegin(TGL_POLYGON); for (int k = 0; k < shadowSector->getNumVertices(); k++) { diff --git a/engines/grim/grim.cpp b/engines/grim/grim.cpp index a0c0ffb3016..a9cac873d3d 100644 --- a/engines/grim/grim.cpp +++ b/engines/grim/grim.cpp @@ -307,10 +307,10 @@ GrimEngine::~GrimEngine() { delete[] _controlsEnabled; delete[] _controlsState; - for (SceneListType::const_iterator i = _scenes.begin(); i != _scenes.end(); i++) + for (SceneListType::const_iterator i = _scenes.begin(); i != _scenes.end(); ++i) delete (*i); - for (ActorListType::const_iterator i = _actors.begin(); i != _actors.end(); i++) + for (ActorListType::const_iterator i = _actors.begin(); i != _actors.end(); ++i) delete (*i); killPrimitiveObjects(); @@ -663,12 +663,12 @@ static void cameraPostChangeHandle(int num) { void GrimEngine::drawPrimitives() { // Draw Primitives - for (PrimitiveListType::iterator i = _primitiveObjects.begin(); i != _primitiveObjects.end(); i++) { + for (PrimitiveListType::iterator i = _primitiveObjects.begin(); i != _primitiveObjects.end(); ++i) { (*i)->draw(); } // Draw text - for (TextListType::iterator i = _textObjects.begin(); i != _textObjects.end(); i++) { + for (TextListType::iterator i = _textObjects.begin(); i != _textObjects.end(); ++i) { (*i)->draw(); } } @@ -774,7 +774,7 @@ void GrimEngine::updateDisplayScene() { _currScene->setupLights(); // Update actor costumes & sets - for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) { + for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); ++i) { Actor *a = *i; // Update the actor's costumes & chores @@ -788,7 +788,7 @@ void GrimEngine::updateDisplayScene() { g_currentUpdatedActor = NULL; // Draw actors - for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) { + for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); ++i) { Actor *a = *i; if (a->inSet(_currScene->name()) && a->visible()) a->draw(); @@ -1051,7 +1051,7 @@ void GrimEngine::saveActors(SaveGame *state) { state->beginSection('ACTR'); state->writeLESint32(_actors.size()); - for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); i++) { + for (ActorListType::iterator i = _actors.begin(); i != _actors.end(); ++i) { Actor *a = *i; PointerId ptr = makeIdFromPointer(a); state->writeLEUint32(ptr.low); @@ -1066,7 +1066,7 @@ void GrimEngine::saveFonts(SaveGame *state) { state->beginSection('FONT'); state->writeLESint32(_fonts.size()); - for (Common::List::iterator i = _fonts.begin(); i != _fonts.end(); i++) { + for (Common::List::iterator i = _fonts.begin(); i != _fonts.end(); ++i) { Font *f = *i; PointerId ptr = makeIdFromPointer(f); state->writeLEUint32(ptr.low); @@ -1098,7 +1098,7 @@ void GrimEngine::saveTextObjects(SaveGame *state) { state->writeLESint32(sayLineDefaults.y); state->writeLESint32(_textObjects.size()); - for (TextListType::iterator i = _textObjects.begin(); i != _textObjects.end(); i++) { + for (TextListType::iterator i = _textObjects.begin(); i != _textObjects.end(); ++i) { TextObject *t = *i; ptr = makeIdFromPointer(t); state->writeLEUint32(ptr.low); @@ -1113,7 +1113,7 @@ void GrimEngine::saveScenes(SaveGame *state) { state->beginSection('SET '); state->writeLESint32(_scenes.size()); - for (SceneListType::iterator i = _scenes.begin(); i != _scenes.end(); i++) { + for (SceneListType::iterator i = _scenes.begin(); i != _scenes.end(); ++i) { Scene *s = *i; s->saveState(state); } @@ -1127,7 +1127,7 @@ void GrimEngine::savePrimitives(SaveGame *state) { state->beginSection('PRIM'); state->writeLESint32(_primitiveObjects.size()); - for (PrimitiveListType::iterator i = _primitiveObjects.begin(); i != _primitiveObjects.end(); i++) { + for (PrimitiveListType::iterator i = _primitiveObjects.begin(); i != _primitiveObjects.end(); ++i) { PrimitiveObject *p = *i; ptr = makeIdFromPointer(p); state->writeLEUint32(ptr.low); @@ -1168,7 +1168,7 @@ void GrimEngine::savegameCallback() { Scene *GrimEngine::findScene(const char *name) { // Find scene object - for (SceneListType::const_iterator i = scenesBegin(); i != scenesEnd(); i++) { + for (SceneListType::const_iterator i = scenesBegin(); i != scenesEnd(); ++i) { if (!strcmp((*i)->name(), name)) return *i; } diff --git a/engines/grim/lua/lmem.cpp b/engines/grim/lua/lmem.cpp index 4f551fdd75a..6c3c8f10214 100644 --- a/engines/grim/lua/lmem.cpp +++ b/engines/grim/lua/lmem.cpp @@ -31,9 +31,7 @@ int32 luaM_growaux(void **block, int32 nelems, int32 size, const char *errormsg, */ void *luaM_realloc(void *block, int32 size) { if (size == 0) { - if (block) { - free(block); - } + free(block); return NULL; } block = block ? realloc(block, size) : malloc(size); diff --git a/engines/grim/lua_v1.cpp b/engines/grim/lua_v1.cpp index ad3ffd61570..a9c802fd54c 100644 --- a/engines/grim/lua_v1.cpp +++ b/engines/grim/lua_v1.cpp @@ -1714,7 +1714,7 @@ static void GetVisibleThings() { lua_Object result = lua_createtable(); // TODO verify code below - for (GrimEngine::ActorListType::const_iterator i = g_grim->actorsBegin(); i != g_grim->actorsEnd(); i++) { + for (GrimEngine::ActorListType::const_iterator i = g_grim->actorsBegin(); i != g_grim->actorsEnd(); ++i) { if (!(*i)->inSet(g_grim->sceneName())) continue; // Consider the active actor visible @@ -2715,7 +2715,7 @@ void GetControlState() { } static void killBitmapPrimitives(Bitmap *bitmap) { - for (GrimEngine::PrimitiveListType::const_iterator i = g_grim->primitivesBegin(); i != g_grim->primitivesEnd(); i++) { + for (GrimEngine::PrimitiveListType::const_iterator i = g_grim->primitivesBegin(); i != g_grim->primitivesEnd(); ++i) { PrimitiveObject *p = *i; if (p->isBitmap() && p->getBitmapHandle() == bitmap) { g_grim->killPrimitiveObject(p); @@ -2987,11 +2987,11 @@ static void GetTextObjectDimensions() { static void ExpireText() { // Expire all the text objects - for (GrimEngine::TextListType::const_iterator i = g_grim->textsBegin(); i != g_grim->textsEnd(); i++) + for (GrimEngine::TextListType::const_iterator i = g_grim->textsBegin(); i != g_grim->textsEnd(); ++i) (*i)->setDisabled(true); // Cleanup actor references to deleted text objects - for (GrimEngine::ActorListType::const_iterator i = g_grim->actorsBegin(); i != g_grim->actorsEnd(); i++) + for (GrimEngine::ActorListType::const_iterator i = g_grim->actorsBegin(); i != g_grim->actorsEnd(); ++i) (*i)->lineCleanup(); } @@ -3232,7 +3232,7 @@ static void ChangePrimitive() { psearch = static_cast(lua_getuserdata(param1)); - for (GrimEngine::PrimitiveListType::const_iterator i = g_grim->primitivesBegin(); i != g_grim->primitivesEnd(); i++) { + for (GrimEngine::PrimitiveListType::const_iterator i = g_grim->primitivesBegin(); i != g_grim->primitivesEnd(); ++i) { PrimitiveObject *p = *i; if (p->getP1().x == psearch->getP1().x && p->getP2().x == psearch->getP2().x && p->getP1().y == psearch->getP1().y && p->getP2().y == psearch->getP2().y) { diff --git a/engines/grim/resource.cpp b/engines/grim/resource.cpp index 93f1c8dfbae..f77fc7c5ce1 100644 --- a/engines/grim/resource.cpp +++ b/engines/grim/resource.cpp @@ -81,12 +81,12 @@ ResourceLoader::ResourceLoader() { } ResourceLoader::~ResourceLoader() { - for (LabList::const_iterator i = _labs.begin(); i != _labs.end(); i++) + for (LabList::const_iterator i = _labs.begin(); i != _labs.end(); ++i) delete *i; } const Lab *ResourceLoader::getLab(const char *filename) const { - for (LabList::const_iterator i = _labs.begin(); i != _labs.end(); i++) + for (LabList::const_iterator i = _labs.begin(); i != _labs.end(); ++i) if ((*i)->fileExists(filename)) return *i; diff --git a/engines/grim/scene.cpp b/engines/grim/scene.cpp index fe11803b7af..e4fb4b44e30 100644 --- a/engines/grim/scene.cpp +++ b/engines/grim/scene.cpp @@ -108,11 +108,9 @@ Scene::Scene(const char *sceneName, const char *buf, int len) : Scene::~Scene() { delete[] _cmaps; delete[] _setups; - if (_lights) - delete[] _lights; - if (_sectors) - delete[] _sectors; - for (StateList::iterator i = _states.begin(); i != _states.end(); i++) + delete[] _lights; + delete[] _sectors; + for (StateList::iterator i = _states.begin(); i != _states.end(); ++i) delete (*i); } @@ -126,7 +124,7 @@ void Scene::saveState(SaveGame *savedState) { savedState->writeLEUint32(_maxVolume); savedState->writeLEUint32(_numObjectStates); - for (StateList::iterator i = _states.begin(); i != _states.end(); i++) { + for (StateList::iterator i = _states.begin(); i != _states.end(); ++i) { // ObjectState *s = *i; } } @@ -240,7 +238,7 @@ void Scene::setSetup(int num) { } void Scene::drawBitmaps(ObjectState::Position stage) { - for (StateList::iterator i = _states.begin(); i != _states.end(); i++) { + for (StateList::iterator i = _states.begin(); i != _states.end(); ++i) { if ((*i)->pos() == stage && _currSetup == _setups + (*i)->setupID()) (*i)->draw(); } @@ -282,7 +280,7 @@ void Scene::findClosestSector(Graphics::Vector3d p, Sector **sect, Graphics::Vec ObjectState *Scene::findState(const char *filename) { // Check the different state objects for the bitmap - for (StateList::iterator i = _states.begin(); i != _states.end(); i++) { + for (StateList::iterator i = _states.begin(); i != _states.end(); ++i) { const char *file = (*i)->bitmapFilename(); if (strcmp(file, filename) == 0) diff --git a/tools/delua.cpp b/tools/delua.cpp index a64f262a7dc..901904b44fb 100644 --- a/tools/delua.cpp +++ b/tools/delua.cpp @@ -149,7 +149,7 @@ public: std::string str(text->str); if (translateStrings) str = g_localizer->localize(str.c_str()).c_str(); - for (std::string::iterator i = str.begin(); i != str.end(); i++) { + for (std::string::iterator i = str.begin(); i != str.end(); ++i) { unsigned char c = *i; if (strchr(specials, c)) { int i = strchr(specials, c) - specials; @@ -272,7 +272,7 @@ public: os << " }"; } ~ArrayExpr() { - for (mapping_list::iterator i = mappings.begin(); i != mappings.end(); i++) { + for (mapping_list::iterator i = mappings.begin(); i != mappings.end(); ++i) { delete i->first; delete i->second; } diff --git a/tools/patchex/patchex.cpp b/tools/patchex/patchex.cpp index c4067642da7..82cf1be1390 100644 --- a/tools/patchex/patchex.cpp +++ b/tools/patchex/patchex.cpp @@ -139,8 +139,7 @@ static void res_close(struct mspack_file *file) { struct mspack_file_p *handle = (struct mspack_file_p *)file; if (handle) { - if (handle->CodeTable) - free(handle->CodeTable); + free(handle->CodeTable); fclose(handle->fh); free(handle); } diff --git a/tools/set2fig.cpp b/tools/set2fig.cpp index 1800cb38f36..f42f20f1974 100644 --- a/tools/set2fig.cpp +++ b/tools/set2fig.cpp @@ -105,4 +105,5 @@ int main(int argc, char *argv[]) { numRead++; } while (numRead < numSectors); + fclose(in); } diff --git a/tools/unlab.cpp b/tools/unlab.cpp index 8284f7c7519..07ddf356f9b 100644 --- a/tools/unlab.cpp +++ b/tools/unlab.cpp @@ -91,8 +91,11 @@ int main(int argc, char **argv) { fread(buf, 1, READ_LE_UINT32(&entries[i].size), infile); fwrite(buf, 1, READ_LE_UINT32(&entries[i].size), outfile); fclose(outfile); + free(buf); } fclose(infile); + free(str_table); + free(entries); return 0; } diff --git a/tools/vima.cpp b/tools/vima.cpp index 995a573501e..608ce1e3c49 100644 --- a/tools/vima.cpp +++ b/tools/vima.cpp @@ -264,5 +264,8 @@ int main(int /* argc */, char *argv[]) { delete[] sourceBuffer; } + delete[] blocks; + delete[] codecs; + fclose(f); return 0; }