[PATCH 04/24] worker: do not use dynamic memory for RedSurfaceCmd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]