diff --git a/tools/quake3/common/bspfile.c b/tools/quake3/common/bspfile.c index f4bea642..a5ba4f7b 100644 --- a/tools/quake3/common/bspfile.c +++ b/tools/quake3/common/bspfile.c @@ -86,9 +86,7 @@ int numFogs; dfog_t dfogs[MAX_MAP_FOGS]; void SetLightBytes( int n ){ - if ( lightBytes != 0 ) { - free( lightBytes ); - } + free( lightBytes ); numLightBytes = n; @@ -100,9 +98,7 @@ void SetLightBytes( int n ){ } void SetGridPoints( int n ){ - if ( gridData != 0 ) { - free( gridData ); - } + free( gridData ); numGridPoints = n; @@ -141,9 +137,7 @@ void IncDrawVerts(){ } void SetDrawVerts( int n ){ - if ( drawVerts != 0 ) { - free( drawVerts ); - } + free( drawVerts ); numDrawVerts = numDrawVertsBuffer = n; @@ -152,9 +146,7 @@ void SetDrawVerts( int n ){ } void SetDrawSurfacesBuffer(){ - if ( drawSurfaces != 0 ) { - free( drawSurfaces ); - } + free( drawSurfaces ); numDrawSurfacesBuffer = MAX_MAP_DRAW_SURFS; @@ -162,9 +154,7 @@ void SetDrawSurfacesBuffer(){ } void SetDrawSurfaces( int n ){ - if ( drawSurfaces != 0 ) { - free( drawSurfaces ); - } + free( drawSurfaces ); numDrawSurfaces = numDrawSurfacesBuffer = n; @@ -173,18 +163,10 @@ void SetDrawSurfaces( int n ){ } void BspFilesCleanup(){ - if ( drawVerts != 0 ) { - free( drawVerts ); - } - if ( drawSurfaces != 0 ) { - free( drawSurfaces ); - } - if ( lightBytes != 0 ) { - free( lightBytes ); - } - if ( gridData != 0 ) { - free( gridData ); - } + free( drawVerts ); + free( drawSurfaces ); + free( lightBytes ); + free( gridData ); } //============================================================================= diff --git a/tools/quake3/q3map2/bspfile_abstract.c b/tools/quake3/q3map2/bspfile_abstract.c index f01bda59..9677c23d 100644 --- a/tools/quake3/q3map2/bspfile_abstract.c +++ b/tools/quake3/q3map2/bspfile_abstract.c @@ -87,9 +87,7 @@ void IncDrawVerts(){ } void SetDrawVerts( int n ){ - if ( bspDrawVerts != 0 ) { - free( bspDrawVerts ); - } + free( bspDrawVerts ); numBSPDrawVerts = numBSPDrawVertsBuffer = n; @@ -99,9 +97,7 @@ void SetDrawVerts( int n ){ int numBSPDrawSurfacesBuffer = 0; void SetDrawSurfacesBuffer(){ - if ( bspDrawSurfaces != 0 ) { - free( bspDrawSurfaces ); - } + free( bspDrawSurfaces ); numBSPDrawSurfacesBuffer = MAX_MAP_DRAW_SURFS; @@ -109,9 +105,7 @@ void SetDrawSurfacesBuffer(){ } void SetDrawSurfaces( int n ){ - if ( bspDrawSurfaces != 0 ) { - free( bspDrawSurfaces ); - } + free( bspDrawSurfaces ); numBSPDrawSurfaces = numBSPDrawSurfacesBuffer = n; @@ -120,18 +114,10 @@ void SetDrawSurfaces( int n ){ } void BSPFilesCleanup(){ - if ( bspDrawVerts != 0 ) { - free( bspDrawVerts ); - } - if ( bspDrawSurfaces != 0 ) { - free( bspDrawSurfaces ); - } - if ( bspLightBytes != 0 ) { - free( bspLightBytes ); - } - if ( bspGridPoints != 0 ) { - free( bspGridPoints ); - } + free( bspDrawVerts ); + free( bspDrawSurfaces ); + free( bspLightBytes ); + free( bspGridPoints ); } diff --git a/tools/quake3/q3map2/image.c b/tools/quake3/q3map2/image.c index 40789375..d6710bac 100644 --- a/tools/quake3/q3map2/image.c +++ b/tools/quake3/q3map2/image.c @@ -267,13 +267,9 @@ void ImageFree( image_t *image ){ /* free? */ if ( image->refCount <= 0 ) { - if ( image->name != NULL ) { - free( image->name ); - } + free( image->name ); image->name = NULL; - if ( image->filename != NULL ) { - free( image->filename ); - } + free( image->filename ); image->filename = NULL; free( image->pixels ); image->width = 0; diff --git a/tools/quake3/q3map2/light.c b/tools/quake3/q3map2/light.c index 730e25f9..a46c9715 100644 --- a/tools/quake3/q3map2/light.c +++ b/tools/quake3/q3map2/light.c @@ -1856,9 +1856,7 @@ void SetupGrid( void ){ /* allocate lightgrid */ rawGridPoints = safe_calloc( numRawGridPoints * sizeof( *rawGridPoints ) ); - if ( bspGridPoints != NULL ) { - free( bspGridPoints ); - } + free( bspGridPoints ); bspGridPoints = safe_calloc( numBSPGridPoints * sizeof( *bspGridPoints ) ); /* clear lightgrid */ diff --git a/tools/quake3/q3map2/light_trace.c b/tools/quake3/q3map2/light_trace.c index 29fa928f..52debdd9 100644 --- a/tools/quake3/q3map2/light_trace.c +++ b/tools/quake3/q3map2/light_trace.c @@ -830,9 +830,7 @@ static int TriangulateTraceNode_r( int nodeNum ){ /* empty node? */ if ( node->numItems == 0 ) { node->maxItems = 0; - if ( node->items != NULL ) { - free( node->items ); - } + free( node->items ); return node->numItems; } @@ -873,9 +871,7 @@ static int TriangulateTraceNode_r( int nodeNum ){ } /* free windings */ - if ( windings != NULL ) { - free( windings ); - } + free( windings ); /* return item count */ return node->numItems; diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index 9347ee58..32d9a8f7 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -3863,9 +3863,7 @@ void SetupEnvelopes( qboolean forGrid, qboolean fastFlag ){ /* delete the light */ numCulledLights++; *owner = light->next; - if ( light->w != NULL ) { - free( light->w ); - } + free( light->w ); free( light ); continue; } @@ -4049,9 +4047,7 @@ void CreateTraceLightsForBounds( vec3_t mins, vec3_t maxs, vec3_t normal, int nu void FreeTraceLights( trace_t *trace ){ - if ( trace->lights != NULL ) { - free( trace->lights ); - } + free( trace->lights ); } diff --git a/tools/quake3/q3map2/lightmaps_ydnar.c b/tools/quake3/q3map2/lightmaps_ydnar.c index bb8accbc..30c0a57e 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.c +++ b/tools/quake3/q3map2/lightmaps_ydnar.c @@ -3155,9 +3155,7 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){ timer_start = I_FloatTime(); /* count the bsp lightmaps and allocate space */ - if ( bspLightBytes != NULL ) { - free( bspLightBytes ); - } + free( bspLightBytes ); if ( numBSPLightmaps == 0 || externalLightmaps ) { numBSPLightBytes = 0; bspLightBytes = NULL; diff --git a/tools/quake3/q3map2/main.c b/tools/quake3/q3map2/main.c index e1e2b679..90a4668b 100644 --- a/tools/quake3/q3map2/main.c +++ b/tools/quake3/q3map2/main.c @@ -48,9 +48,7 @@ static void ExitQ3Map( void ){ /* flush xml send buffer, shut down connection */ Broadcast_Shutdown(); BSPFilesCleanup(); - if ( mapDrawSurfs != NULL ) { - free( mapDrawSurfs ); - } + free( mapDrawSurfs ); } diff --git a/tools/quake3/q3map2/minimap.c b/tools/quake3/q3map2/minimap.c index 477a2341..aa2ea7b2 100644 --- a/tools/quake3/q3map2/minimap.c +++ b/tools/quake3/q3map2/minimap.c @@ -522,9 +522,7 @@ int MiniMapBSPMain( int argc, char **argv ){ minimap.samples = atoi( argv[i + 1] ); i++; Sys_Printf( "Samples set to %i\n", minimap.samples ); - if ( minimap.sample_offsets ) { - free( minimap.sample_offsets ); - } + free( minimap.sample_offsets ); minimap.sample_offsets = malloc( 2 * sizeof( *minimap.sample_offsets ) * minimap.samples ); MiniMapMakeSampleOffsets(); } @@ -532,9 +530,7 @@ int MiniMapBSPMain( int argc, char **argv ){ minimap.samples = atoi( argv[i + 1] ); i++; Sys_Printf( "Random samples set to %i\n", minimap.samples ); - if ( minimap.sample_offsets ) { - free( minimap.sample_offsets ); - } + free( minimap.sample_offsets ); minimap.sample_offsets = NULL; } else if ( !strcmp( argv[ i ], "-border" ) ) { diff --git a/tools/quake3/q3map2/surface.c b/tools/quake3/q3map2/surface.c index f7033705..95afe582 100644 --- a/tools/quake3/q3map2/surface.c +++ b/tools/quake3/q3map2/surface.c @@ -277,14 +277,10 @@ void ClearSurface( mapDrawSurface_t *ds ){ ds->planar = qfalse; ds->planeNum = -1; ds->numVerts = 0; - if ( ds->verts != NULL ) { - free( ds->verts ); - } + free( ds->verts ); ds->verts = NULL; ds->numIndexes = 0; - if ( ds->indexes != NULL ) { - free( ds->indexes ); - } + free( ds->indexes ); ds->indexes = NULL; numClearedSurfaces++; }