[Spice-devel] [PATCH 04/24] worker: do not use dynamic memory for RedSurfaceCmd
Frediano Ziglio
fziglio at redhat.com
Tue Dec 1 04:05:16 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/red_worker.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/server/red_worker.c b/server/red_worker.c
index ee26b63..cf61108 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -200,7 +200,7 @@ static inline void red_process_surface(RedWorker *worker, RedSurfaceCmd *surface
surface_id = surface->surface_id;
if SPICE_UNLIKELY(surface_id >= display->n_surfaces) {
- goto exit;
+ return;
}
red_surface = &display->surfaces[surface_id];
@@ -238,9 +238,6 @@ static inline void red_process_surface(RedWorker *worker, RedSurfaceCmd *surface
default:
spice_warn_if_reached();
};
-exit:
- red_put_surface_cmd(surface);
- free(surface);
}
static int red_process_cursor(RedWorker *worker, uint32_t max_pipe_size, int *ring_is_empty)
@@ -390,14 +387,15 @@ 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;
}
- red_process_surface(worker, surface, ext_cmd.group_id, FALSE);
+ red_process_surface(worker, &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