[Spice-devel] [PATCH 04/22] worker: do not use dynamic memory for RedSurfaceCmd
Frediano Ziglio
fziglio at redhat.com
Wed Dec 2 08:19:47 PST 2015
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 at redhat.com>
---
server/display-channel.c | 5 +----
server/red_worker.c | 9 +++++----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/server/display-channel.c b/server/display-channel.c
index 43f2e0e..809673b 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2081,7 +2081,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];
@@ -2119,9 +2119,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)
diff --git a/server/red_worker.c b/server/red_worker.c
index 329c2ef..f2c3126 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -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:
--
2.4.3
More information about the Spice-devel
mailing list