change iterator erasing so we don't need to overload the = operator

This commit is contained in:
Jonathan Gray 2013-04-28 12:51:04 +10:00
parent bdaaf508db
commit 4b44474789
3 changed files with 6 additions and 51 deletions

View file

@ -406,15 +406,7 @@ qboolean CROFFSystem::Unload( int id )
{ // requested item found in the list, free mem, then remove from list { // requested item found in the list, free mem, then remove from list
delete ((CROFF *)(*itr).second); delete ((CROFF *)(*itr).second);
#ifndef __linux__ mROFFList.erase( itr++ );
itr = mROFFList.erase( itr );
#else
// darn stl differences
TROFFList::iterator titr;
titr = itr;
itr++;
mROFFList.erase(titr);
#endif
#ifdef _DEBUG #ifdef _DEBUG
Com_Printf( S_COLOR_GREEN"roff unloaded\n" ); Com_Printf( S_COLOR_GREEN"roff unloaded\n" );

View file

@ -795,15 +795,8 @@ void R_Images_DeleteLightMaps(void)
if (pImage->imgName[0] == '*' && strstr(pImage->imgName,"lightmap")) // loose check, but should be ok if (pImage->imgName[0] == '*' && strstr(pImage->imgName,"lightmap")) // loose check, but should be ok
{ {
R_Images_DeleteImageContents(pImage); R_Images_DeleteImageContents(pImage);
#ifndef __linux__ AllocatedImages.erase(itImage++);
itImage = AllocatedImages.erase(itImage);
bEraseOccured = qtrue; bEraseOccured = qtrue;
#else
// MS & Dinkimware got the map::erase return wrong (it's null)
AllocatedImages_t::iterator itTemp = itImage;
itImage++;
AllocatedImages.erase(itTemp);
#endif
} }
} }
@ -899,14 +892,8 @@ qboolean RE_RegisterImages_LevelLoadEnd(void)
ri.Printf( PRINT_DEVELOPER, "Dumping image \"%s\"\n",pImage->imgName); ri.Printf( PRINT_DEVELOPER, "Dumping image \"%s\"\n",pImage->imgName);
R_Images_DeleteImageContents(pImage); R_Images_DeleteImageContents(pImage);
#ifndef __linux__ AllocatedImages.erase(itImage++);
itImage = AllocatedImages.erase(itImage);
bEraseOccured = qtrue; bEraseOccured = qtrue;
#else
AllocatedImages_t::iterator itTemp = itImage;
itImage++;
AllocatedImages.erase(itTemp);
#endif
} }
} }
} }

View file

@ -361,18 +361,8 @@ qboolean RE_RegisterModels_LevelLoadEnd(qboolean bDeleteEverythingNotUsedThisLev
//CachedModel.pModelDiskImage = NULL; // REM for reference, erase() call below negates the need for it. //CachedModel.pModelDiskImage = NULL; // REM for reference, erase() call below negates the need for it.
bAtLeastoneModelFreed = qtrue; bAtLeastoneModelFreed = qtrue;
} }
#ifndef __linux__ CachedModels.erase(itModel++);
itModel = CachedModels.erase(itModel);
bEraseOccured = qtrue; bEraseOccured = qtrue;
#else
// Both MS and Dinkumware got the map::erase wrong
// The STL has the return type as a void
CachedModels_t::iterator itTemp;
itTemp = itModel;
itModel++;
CachedModels.erase(itTemp);
#endif
iLoadedModelBytes = GetModelDataAllocSize(); iLoadedModelBytes = GetModelDataAllocSize();
} }
@ -418,18 +408,8 @@ static void RE_RegisterModels_DumpNonPure(void)
Z_Free(CachedModel.pModelDiskImage); Z_Free(CachedModel.pModelDiskImage);
//CachedModel.pModelDiskImage = NULL; // REM for reference, erase() call below negates the need for it. //CachedModel.pModelDiskImage = NULL; // REM for reference, erase() call below negates the need for it.
} }
#ifndef __linux__ CachedModels.erase(itModel++);
itModel = CachedModels.erase(itModel);
bEraseOccured = qtrue; bEraseOccured = qtrue;
#else
// Both MS and Dinkumware got the map::erase wrong
// The STL has the return type as a void
CachedModels_t::iterator itTemp;
itTemp = itModel;
itModel++;
CachedModels.erase(itTemp);
#endif
} }
} }
} }
@ -462,7 +442,6 @@ void RE_RegisterModels_Info_f( void )
// //
static void RE_RegisterModels_DeleteAll(void) static void RE_RegisterModels_DeleteAll(void)
{ {
#ifndef __linux__
for (CachedModels_t::iterator itModel = CachedModels.begin(); itModel != CachedModels.end(); ) for (CachedModels_t::iterator itModel = CachedModels.begin(); itModel != CachedModels.end(); )
{ {
CachedEndianedModelBinary_t &CachedModel = (*itModel).second; CachedEndianedModelBinary_t &CachedModel = (*itModel).second;
@ -471,11 +450,8 @@ static void RE_RegisterModels_DeleteAll(void)
Z_Free(CachedModel.pModelDiskImage); Z_Free(CachedModel.pModelDiskImage);
} }
itModel = CachedModels.erase(itModel); CachedModels.erase(itModel++);
} }
#else
CachedModels.erase(CachedModels.begin(),CachedModels.end());
#endif
} }