don't check for NULL, while doing free()
This commit is contained in:
parent
67820df935
commit
dfae69d446
|
|
@ -86,9 +86,7 @@ int numFogs;
|
|||
dfog_t dfogs[MAX_MAP_FOGS];
|
||||
|
||||
void SetLightBytes( int n ){
|
||||
if ( lightBytes != 0 ) {
|
||||
free( lightBytes );
|
||||
}
|
||||
|
||||
numLightBytes = n;
|
||||
|
||||
|
|
@ -100,9 +98,7 @@ void SetLightBytes( int n ){
|
|||
}
|
||||
|
||||
void SetGridPoints( int n ){
|
||||
if ( gridData != 0 ) {
|
||||
free( gridData );
|
||||
}
|
||||
|
||||
numGridPoints = n;
|
||||
|
||||
|
|
@ -141,9 +137,7 @@ void IncDrawVerts(){
|
|||
}
|
||||
|
||||
void SetDrawVerts( int n ){
|
||||
if ( drawVerts != 0 ) {
|
||||
free( drawVerts );
|
||||
}
|
||||
|
||||
numDrawVerts =
|
||||
numDrawVertsBuffer = n;
|
||||
|
|
@ -152,9 +146,7 @@ void SetDrawVerts( int n ){
|
|||
}
|
||||
|
||||
void SetDrawSurfacesBuffer(){
|
||||
if ( drawSurfaces != 0 ) {
|
||||
free( drawSurfaces );
|
||||
}
|
||||
|
||||
numDrawSurfacesBuffer = MAX_MAP_DRAW_SURFS;
|
||||
|
||||
|
|
@ -162,9 +154,7 @@ void SetDrawSurfacesBuffer(){
|
|||
}
|
||||
|
||||
void SetDrawSurfaces( int n ){
|
||||
if ( drawSurfaces != 0 ) {
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
|||
|
|
@ -87,9 +87,7 @@ void IncDrawVerts(){
|
|||
}
|
||||
|
||||
void SetDrawVerts( int n ){
|
||||
if ( bspDrawVerts != 0 ) {
|
||||
free( bspDrawVerts );
|
||||
}
|
||||
|
||||
numBSPDrawVerts =
|
||||
numBSPDrawVertsBuffer = n;
|
||||
|
|
@ -99,9 +97,7 @@ void SetDrawVerts( int n ){
|
|||
|
||||
int numBSPDrawSurfacesBuffer = 0;
|
||||
void SetDrawSurfacesBuffer(){
|
||||
if ( bspDrawSurfaces != 0 ) {
|
||||
free( bspDrawSurfaces );
|
||||
}
|
||||
|
||||
numBSPDrawSurfacesBuffer = MAX_MAP_DRAW_SURFS;
|
||||
|
||||
|
|
@ -109,9 +105,7 @@ void SetDrawSurfacesBuffer(){
|
|||
}
|
||||
|
||||
void SetDrawSurfaces( int n ){
|
||||
if ( bspDrawSurfaces != 0 ) {
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -267,13 +267,9 @@ void ImageFree( image_t *image ){
|
|||
|
||||
/* free? */
|
||||
if ( image->refCount <= 0 ) {
|
||||
if ( image->name != NULL ) {
|
||||
free( image->name );
|
||||
}
|
||||
image->name = NULL;
|
||||
if ( image->filename != NULL ) {
|
||||
free( image->filename );
|
||||
}
|
||||
image->filename = NULL;
|
||||
free( image->pixels );
|
||||
image->width = 0;
|
||||
|
|
|
|||
|
|
@ -1856,9 +1856,7 @@ void SetupGrid( void ){
|
|||
/* allocate lightgrid */
|
||||
rawGridPoints = safe_calloc( numRawGridPoints * sizeof( *rawGridPoints ) );
|
||||
|
||||
if ( bspGridPoints != NULL ) {
|
||||
free( bspGridPoints );
|
||||
}
|
||||
bspGridPoints = safe_calloc( numBSPGridPoints * sizeof( *bspGridPoints ) );
|
||||
|
||||
/* clear lightgrid */
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
return node->numItems;
|
||||
}
|
||||
|
||||
|
|
@ -873,9 +871,7 @@ static int TriangulateTraceNode_r( int nodeNum ){
|
|||
}
|
||||
|
||||
/* free windings */
|
||||
if ( windings != NULL ) {
|
||||
free( windings );
|
||||
}
|
||||
|
||||
/* return item count */
|
||||
return node->numItems;
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3155,9 +3155,7 @@ void StoreSurfaceLightmaps( qboolean fastAllocate ){
|
|||
timer_start = I_FloatTime();
|
||||
|
||||
/* count the bsp lightmaps and allocate space */
|
||||
if ( bspLightBytes != NULL ) {
|
||||
free( bspLightBytes );
|
||||
}
|
||||
if ( numBSPLightmaps == 0 || externalLightmaps ) {
|
||||
numBSPLightBytes = 0;
|
||||
bspLightBytes = NULL;
|
||||
|
|
|
|||
|
|
@ -48,9 +48,7 @@ static void ExitQ3Map( void ){
|
|||
/* flush xml send buffer, shut down connection */
|
||||
Broadcast_Shutdown();
|
||||
BSPFilesCleanup();
|
||||
if ( mapDrawSurfs != NULL ) {
|
||||
free( mapDrawSurfs );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
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 );
|
||||
}
|
||||
minimap.sample_offsets = NULL;
|
||||
}
|
||||
else if ( !strcmp( argv[ i ], "-border" ) ) {
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
ds->verts = NULL;
|
||||
ds->numIndexes = 0;
|
||||
if ( ds->indexes != NULL ) {
|
||||
free( ds->indexes );
|
||||
}
|
||||
ds->indexes = NULL;
|
||||
numClearedSurfaces++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user