Silenced a bunch of mostly harmless cppcheck warnings.

This commit is contained in:
Torbjorn Andersson 2010-02-04 19:43:50 +00:00
parent e6d209a4d4
commit 20a5e580b7
17 changed files with 47 additions and 45 deletions

View file

@ -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();

View file

@ -53,7 +53,7 @@ void ImageMap::removeArea(const String& id) {
void ImageMap::removeAllAreas() {
HashMap<String, Polygon*>::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<String, Polygon*>::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;
}

View file

@ -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;
}
}

View file

@ -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;

View file

@ -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<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); i++)
for (Common::List<Costume *>::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<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); i++) {
for (Common::List<Costume *>::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<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); i++)
for (Common::List<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); ++i)
(*i)->setupTextures();
if (!g_driver->isHardwareAccelerated() && g_grim->getFlagRefreshShadowMask()) {

View file

@ -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++) {

View file

@ -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++) {

View file

@ -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<Font *>::iterator i = _fonts.begin(); i != _fonts.end(); i++) {
for (Common::List<Font *>::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;
}

View file

@ -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);

View file

@ -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<PrimitiveObject *>(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) {

View file

@ -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;

View file

@ -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)

View file

@ -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;
}

View file

@ -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);
}

View file

@ -105,4 +105,5 @@ int main(int argc, char *argv[]) {
numRead++;
} while (numRead < numSectors);
fclose(in);
}

View file

@ -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;
}

View file

@ -264,5 +264,8 @@ int main(int /* argc */, char *argv[]) {
delete[] sourceBuffer;
}
delete[] blocks;
delete[] codecs;
fclose(f);
return 0;
}