Remove useless if() before free()

The free() function allows NULL to be passed in, so any
code which puts a if() before free() is wasting time
This commit is contained in:
Daniel P. Berrange 2011-12-12 17:53:04 +00:00 committed by Marc-André Lureau
parent bcdf929c79
commit 4a9f7971fc
7 changed files with 12 additions and 31 deletions

View File

@ -749,9 +749,7 @@ static pixman_image_t *canvas_get_lz(CanvasBase *canvas, SpiceImage *image, int
int free_palette;
if (setjmp(lz_data->jmp_env)) {
if (decomp_buf) {
free(decomp_buf);
}
free(decomp_buf);
CANVAS_ERROR("lz error, %s", lz_data->message_buf);
}
@ -3134,9 +3132,7 @@ static void canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox,
stroke_lines_draw(&lines, (lineGC *)&gc, dashed);
if (gc.base.dash) {
free(gc.base.dash);
}
free(gc.base.dash);
stroke_lines_free(&lines);
if (!gc.solid && gc.tile && !surface_canvas) {

View File

@ -51,9 +51,7 @@ static void release_data(pixman_image_t *image, void *release_data)
gdi_handlers--;
}
#endif
if (data->data) {
free(data->data);
}
free(data->data);
free(data);
}

View File

@ -1773,9 +1773,7 @@ static void gdi_canvas_draw_stroke(SpiceCanvas *spice_canvas, SpiceRect *bbox, S
}
#endif
if (user_style) {
free(user_style);
}
free(user_style);
}
static void gdi_canvas_clear(SpiceCanvas *spice_canvas)

View File

@ -870,9 +870,7 @@ static void gl_canvas_destroy(SpiceCanvas *spice_canvas)
}
canvas_base_destroy(&canvas->base);
glc_destroy(canvas->glc, canvas->textures_lost);
if (canvas->private_data) {
free(canvas->private_data);
}
free(canvas->private_data);
free(canvas);
}

View File

@ -580,8 +580,7 @@ miAppendSpans (SpanGroup * spanGroup, SpanGroup * otherGroup, Spans * spans)
static void
miFreeSpanGroup (SpanGroup * spanGroup)
{
if (spanGroup->group != NULL)
xfree (spanGroup->group);
xfree (spanGroup->group);
}
static void
@ -776,10 +775,8 @@ miFillUniqueSpanGroup (GCPtr pGC, SpanGroup * spanGroup, Boolean foreground)
ysizes = (int *)xalloc (ylength * sizeof (int));
if (!yspans || !ysizes) {
if (yspans)
xfree (yspans);
if (ysizes)
xfree (ysizes);
xfree (yspans);
xfree (ysizes);
miDisposeSpanGroup (spanGroup);
return;
}
@ -849,10 +846,8 @@ miFillUniqueSpanGroup (GCPtr pGC, SpanGroup * spanGroup, Boolean foreground)
}
xfree (yspans);
xfree (ysizes);
if (points)
xfree (points);
if (widths)
xfree (widths);
xfree (points);
xfree (widths);
return;
}
count = 0;

View File

@ -130,9 +130,7 @@ void *spice_realloc(void *mem, size_t n_bytes)
(unsigned long)n_bytes);
}
if (mem) {
free(mem);
}
free(mem);
return NULL;
}

View File

@ -1166,9 +1166,7 @@ static void canvas_destroy(SpiceCanvas *spice_canvas)
}
pixman_image_unref(canvas->image);
canvas_base_destroy(&canvas->base);
if (canvas->private_data) {
free(canvas->private_data);
}
free(canvas->private_data);
free(canvas);
}