[Spice-devel] [PATCH spice-gtk 11/14] gtk: use slices for frequently allocated objects

Marc-André Lureau marcandre.lureau at gmail.com
Thu Sep 12 05:09:19 PDT 2013


From: Marc-André Lureau <marcandre.lureau at gmail.com>

---
 gtk/channel-display.c | 4 ++--
 gtk/spice-channel.c   | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index 45d31c5..0af3859 100644
--- a/gtk/channel-display.c
+++ b/gtk/channel-display.c
@@ -657,7 +657,7 @@ static void destroy_surface(gpointer data)
     display_surface *surface = data;
 
     destroy_canvas(surface);
-    free(surface);
+    g_slice_free(display_surface, surface);
 }
 
 static void spice_display_channel_init(SpiceDisplayChannel *channel)
@@ -1687,7 +1687,7 @@ static void display_handle_surface_create(SpiceChannel *channel, SpiceMsgIn *in)
 {
     SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)->priv;
     SpiceMsgSurfaceCreate *create = spice_msg_in_parsed(in);
-    display_surface *surface = spice_new0(display_surface, 1);
+    display_surface *surface = g_slice_new0(display_surface);
 
     surface->surface_id = create->surface_id;
     surface->format = create->format;
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index f6a691e..14c526c 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -462,7 +462,7 @@ SpiceMsgIn *spice_msg_in_new(SpiceChannel *channel)
 
     g_return_val_if_fail(channel != NULL, NULL);
 
-    in = spice_new0(SpiceMsgIn, 1);
+    in = g_slice_new0(SpiceMsgIn);
     in->refcount = 1;
     in->channel  = channel;
 
@@ -510,7 +510,7 @@ void spice_msg_in_unref(SpiceMsgIn *in)
     } else {
         free(in->data);
     }
-    free(in);
+    g_slice_free(SpiceMsgIn, in);
 }
 
 G_GNUC_INTERNAL
@@ -615,7 +615,7 @@ SpiceMsgOut *spice_msg_out_new(SpiceChannel *channel, int type)
 
     g_return_val_if_fail(c != NULL, NULL);
 
-    out = spice_new0(SpiceMsgOut, 1);
+    out = g_slice_new0(SpiceMsgOut);
     out->refcount = 1;
     out->channel  = channel;
     out->ro_check = msg_check_read_only(c->channel_type, type);
@@ -651,7 +651,7 @@ void spice_msg_out_unref(SpiceMsgOut *out)
     if (out->refcount > 0)
         return;
     spice_marshaller_destroy(out->marshaller);
-    free(out);
+    g_slice_free(SpiceMsgOut, out);
 }
 
 /* system context */
-- 
1.8.3.1



More information about the Spice-devel mailing list