mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-06 09:39:13 +00:00
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:
parent
64f4826b6d
commit
faf0947ebb
@ -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) {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -129,8 +129,7 @@ static boolean empty_mem_output_buffer(j_compress_ptr cinfo)
|
||||
|
||||
memcpy(nextbuffer, dest->buffer, dest->bufsize);
|
||||
|
||||
if (dest->newbuffer != NULL)
|
||||
free(dest->newbuffer);
|
||||
free(dest->newbuffer);
|
||||
|
||||
dest->newbuffer = nextbuffer;
|
||||
|
||||
|
||||
@ -409,9 +409,7 @@ void red_put_image(SpiceImage *red)
|
||||
|
||||
switch (red->descriptor.type) {
|
||||
case SPICE_IMAGE_TYPE_BITMAP:
|
||||
if (red->u.bitmap.palette) {
|
||||
free(red->u.bitmap.palette);
|
||||
}
|
||||
free(red->u.bitmap.palette);
|
||||
spice_chunks_destroy(red->u.bitmap.data);
|
||||
break;
|
||||
case SPICE_IMAGE_TYPE_QUIC:
|
||||
|
||||
@ -2472,9 +2472,7 @@ static void red_display_release_stream_clip(RedWorker *worker, StreamClipItem *i
|
||||
{
|
||||
if (!--item->refs) {
|
||||
red_display_release_stream(worker, item->stream_agent);
|
||||
if (item->rects) {
|
||||
free(item->rects);
|
||||
}
|
||||
free(item->rects);
|
||||
free(item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,9 +29,7 @@ static void test_spice_destroy_update(SimpleSpiceUpdate *update)
|
||||
if (!update) {
|
||||
return;
|
||||
}
|
||||
if (update->bitmap) {
|
||||
free(update->bitmap);
|
||||
}
|
||||
free(update->bitmap);
|
||||
free(update);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user