Re: [PATCH spice-gtk 09/10] gtk: use slices for frequently allocated objects

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

 



ack, but what happens when g_slice_new fails? the spice_new and other spice malloc functions handle mallocs that fail and abort in such cases.


On 09/08/2013 02:59 PM, Marc-André Lureau wrote:
From: Marc-André Lureau <marcandre.lureau@xxxxxxxxx>

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

diff --git a/gtk/channel-display.c b/gtk/channel-display.c
index a69f14f..8629eee 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 9fb3b0c..4b80029 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 */
diff --git a/spice-common b/spice-common
index 7aef065..ab6fb3c 160000
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit 7aef06577e47965bbe93e0a054857a562d2fde5a
+Subproject commit ab6fb3c176b090cffedeb53d9b03f8399bd51ace


_______________________________________________
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]