summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2012-09-03 20:24:35 -0700
committerMatt Turner <[email protected]>2012-09-05 22:28:50 -0700
commit5067506ea6ada5eeae33b1acf1c916e00121c12a (patch)
treea6b4ff2e3cf5fb6058101aee3b6f1dcd3f382c15 /src/mesa/swrast
parenta9e8054fffc6e3e6a5f108a96c331858c28a5862 (diff)
Remove useless checks for NULL before freeing
This patch has been generated by the following Coccinelle semantic patch: // Remove useless checks for NULL before freeing // // free (NULL) is a no-op, so there is no need to avoid it @@ expression E; @@ + free (E); + E = NULL; - if (unlikely (E != NULL)) { - free(E); ( - E = NULL; | - E = 0; ) ... - } @@ expression E; type T; @@ + free ((T) E); + E = NULL; - if (unlikely (E != NULL)) { - free((T) E); ( - E = NULL; | - E = 0; ) ... - } @@ expression E; @@ + free (E); - if (unlikely (E != NULL)) { - free (E); - } @@ expression E; type T; @@ + free ((T) E); - if (unlikely (E != NULL)) { - free ((T) E); - } Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_context.c3
-rw-r--r--src/mesa/swrast/s_drawpix.c4
-rw-r--r--src/mesa/swrast/s_renderbuffer.c12
-rw-r--r--src/mesa/swrast/s_texture.c6
4 files changed, 8 insertions, 17 deletions
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index d5acaee8312..31a12dade1a 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -829,8 +829,7 @@ _swrast_DestroyContext( struct gl_context *ctx )
}
free( swrast->SpanArrays );
- if (swrast->ZoomedArrays)
- free( swrast->ZoomedArrays );
+ free( swrast->ZoomedArrays );
free( swrast->TexelBuffer );
free(swrast->stencil_temp.buf1);
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index 93d2d352922..7665408fd13 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -493,9 +493,7 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,
span.array->ChanType = CHAN_TYPE;
}
- if (convImage) {
- free(convImage);
- }
+ free(convImage);
swrast_render_finish(ctx);
}
diff --git a/src/mesa/swrast/s_renderbuffer.c b/src/mesa/swrast/s_renderbuffer.c
index e468bdb16b0..b1fb57823f4 100644
--- a/src/mesa/swrast/s_renderbuffer.c
+++ b/src/mesa/swrast/s_renderbuffer.c
@@ -119,10 +119,8 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
bpp = _mesa_get_format_bytes(rb->Format);
/* free old buffer storage */
- if (srb->Buffer) {
- free(srb->Buffer);
- srb->Buffer = NULL;
- }
+ free(srb->Buffer);
+ srb->Buffer = NULL;
srb->RowStride = width * bpp;
@@ -170,10 +168,8 @@ soft_renderbuffer_delete(struct gl_renderbuffer *rb)
{
struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
- if (srb->Buffer) {
- free(srb->Buffer);
- srb->Buffer = NULL;
- }
+ free(srb->Buffer);
+ srb->Buffer = NULL;
_mesa_delete_renderbuffer(rb);
}
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index defe669941f..8ae3d5bd0e6 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -144,10 +144,8 @@ _swrast_free_texture_image_buffer(struct gl_context *ctx,
swImage->Buffer = NULL;
}
- if (swImage->ImageOffsets) {
- free(swImage->ImageOffsets);
- swImage->ImageOffsets = NULL;
- }
+ free(swImage->ImageOffsets);
+ swImage->ImageOffsets = NULL;
}