worker: do not use dynamic memory for RedSurfaceCmd

Allocation on stack is sufficient and code is more similar to
QXL_CMD_MESSAGE and QXL_CMD_UPDATE cases.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
Frediano Ziglio 2015-11-30 18:06:34 +00:00
parent c1ecbaf7b1
commit 768dfa2139
2 changed files with 6 additions and 8 deletions

View File

@ -2078,7 +2078,7 @@ void display_channel_process_surface_cmd(DisplayChannel *display, RedSurfaceCmd
surface_id = surface->surface_id;
if SPICE_UNLIKELY(surface_id >= display->n_surfaces) {
goto exit;
return;
}
red_surface = &display->surfaces[surface_id];
@ -2116,9 +2116,6 @@ void display_channel_process_surface_cmd(DisplayChannel *display, RedSurfaceCmd
default:
spice_warn_if_reached();
};
exit:
red_put_surface_cmd(surface);
free(surface);
}
void display_channel_update_compression(DisplayChannel *display, DisplayChannelClient *dcc)

View File

@ -329,15 +329,16 @@ static int red_process_commands(RedWorker *worker, uint32_t max_pipe_size, int *
break;
}
case QXL_CMD_SURFACE: {
RedSurfaceCmd *surface = spice_new0(RedSurfaceCmd, 1);
RedSurfaceCmd surface;
if (red_get_surface_cmd(&worker->mem_slots, ext_cmd.group_id,
surface, ext_cmd.cmd.data)) {
free(surface);
&surface, ext_cmd.cmd.data)) {
break;
}
display_channel_process_surface_cmd(worker->display_channel, surface,
display_channel_process_surface_cmd(worker->display_channel, &surface,
ext_cmd.group_id, FALSE);
// do not release resource as is released inside red_process_surface
red_put_surface_cmd(&surface);
break;
}
default: