[Spice-devel] [PATCH] Remove GSLice usage
Marc-André Lureau
mlureau at redhat.com
Mon Jan 18 01:15:36 PST 2016
Hi
----- Original Message -----
> It's being slowly deprecated im glib
> https://bugzilla.gnome.org/show_bug.cgi?id=754687
> ---
> src/channel-display.c | 6 +++---
> src/channel-smartcard.c | 4 ++--
> src/spice-channel-cache.h | 8 ++++----
> src/spice-channel.c | 8 ++++----
> src/spice-grabsequence.c | 8 ++++----
> src/spice-util.c | 4 ++--
> src/wocky-http-proxy.c | 4 ++--
> 7 files changed, 21 insertions(+), 21 deletions(-)
>
> diff --git a/src/channel-display.c b/src/channel-display.c
> index dc73235..6a474b1 100644
> --- a/src/channel-display.c
> +++ b/src/channel-display.c
> @@ -635,7 +635,7 @@ static void destroy_surface(gpointer data)
> display_surface *surface = data;
>
> destroy_canvas(surface);
> - g_slice_free(display_surface, surface);
> + g_free(surface);
> }
>
> static void spice_display_channel_init(SpiceDisplayChannel *channel)
> @@ -869,7 +869,7 @@ static void display_handle_mode(SpiceChannel *channel,
> SpiceMsgIn *in)
>
> g_warn_if_fail(c->mark == FALSE);
>
> - surface = g_slice_new0(display_surface);
> + surface = g_new0(display_surface, 1);
> surface->format = mode->bits == 32 ?
> SPICE_SURFACE_FMT_32_xRGB : SPICE_SURFACE_FMT_16_555;
> surface->width = mode->x_res;
> @@ -1674,7 +1674,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 = g_slice_new0(display_surface);
> + display_surface *surface = g_new0(display_surface, 1);
>
> surface->surface_id = create->surface_id;
> surface->format = create->format;
> diff --git a/src/channel-smartcard.c b/src/channel-smartcard.c
> index b5535e6..e2e1aad 100644
> --- a/src/channel-smartcard.c
> +++ b/src/channel-smartcard.c
> @@ -241,7 +241,7 @@ smartcard_message_free(SpiceSmartcardChannelMessage
> *message)
> {
> if (message->message)
> spice_msg_out_unref(message->message);
> - g_slice_free(SpiceSmartcardChannelMessage, message);
> + g_free(message);
> }
>
> #if USE_SMARTCARD
> @@ -301,7 +301,7 @@ smartcard_message_new(VSCMsgType msg_type, SpiceMsgOut
> *msg_out)
> {
> SpiceSmartcardChannelMessage *message;
>
> - message = g_slice_new0(SpiceSmartcardChannelMessage);
> + message = g_new0(SpiceSmartcardChannelMessage, 1);
> message->message = msg_out;
> message->message_type = msg_type;
>
> diff --git a/src/spice-channel-cache.h b/src/spice-channel-cache.h
> index e609a67..75cc2cd 100644
> --- a/src/spice-channel-cache.h
> +++ b/src/spice-channel-cache.h
> @@ -37,7 +37,7 @@ typedef struct display_cache {
>
> static inline display_cache_item* cache_item_new(guint64 id, gboolean lossy)
> {
> - display_cache_item *self = g_slice_new(display_cache_item);
> + display_cache_item *self = g_new(display_cache_item, 1);
> self->id = id;
> self->lossy = lossy;
> self->ref_count = 1;
> @@ -46,12 +46,12 @@ static inline display_cache_item* cache_item_new(guint64
> id, gboolean lossy)
>
> static inline void cache_item_free(display_cache_item *self)
> {
> - g_slice_free(display_cache_item, self);
> + g_free(self);
> }
>
> static inline display_cache* cache_new(GDestroyNotify value_destroy)
> {
> - display_cache * self = g_slice_new(display_cache);
> + display_cache * self = g_new(display_cache, 1);
> self->table = g_hash_table_new_full(g_int64_hash, g_int64_equal,
> (GDestroyNotify) cache_item_free,
> value_destroy);
> @@ -131,7 +131,7 @@ static inline void cache_clear(display_cache *cache)
> static inline void cache_free(display_cache *cache)
> {
> g_hash_table_unref(cache->table);
> - g_slice_free(display_cache, cache);
> + g_free(cache);
> }
>
> G_END_DECLS
> diff --git a/src/spice-channel.c b/src/spice-channel.c
> index 41c94d0..ff85715 100644
> --- a/src/spice-channel.c
> +++ b/src/spice-channel.c
> @@ -471,7 +471,7 @@ SpiceMsgIn *spice_msg_in_new(SpiceChannel *channel)
>
> g_return_val_if_fail(channel != NULL, NULL);
>
> - in = g_slice_new0(SpiceMsgIn);
> + in = g_new0(SpiceMsgIn, 1);
> in->refcount = 1;
> in->channel = channel;
>
> @@ -519,7 +519,7 @@ void spice_msg_in_unref(SpiceMsgIn *in)
> } else {
> g_free(in->data);
> }
> - g_slice_free(SpiceMsgIn, in);
> + g_free(in);
> }
>
> G_GNUC_INTERNAL
> @@ -624,7 +624,7 @@ SpiceMsgOut *spice_msg_out_new(SpiceChannel *channel, int
> type)
>
> g_return_val_if_fail(c != NULL, NULL);
>
> - out = g_slice_new0(SpiceMsgOut);
> + out = g_new0(SpiceMsgOut, 1);
> out->refcount = 1;
> out->channel = channel;
> out->ro_check = msg_check_read_only(c->channel_type, type);
> @@ -660,7 +660,7 @@ void spice_msg_out_unref(SpiceMsgOut *out)
> if (out->refcount > 0)
> return;
> spice_marshaller_destroy(out->marshaller);
> - g_slice_free(SpiceMsgOut, out);
> + g_free(out);
> }
>
> /* system context */
> diff --git a/src/spice-grabsequence.c b/src/spice-grabsequence.c
> index 26bf96f..3d87329 100644
> --- a/src/spice-grabsequence.c
> +++ b/src/spice-grabsequence.c
> @@ -56,7 +56,7 @@ SpiceGrabSequence *spice_grab_sequence_new(guint nkeysyms,
> guint *keysyms)
> {
> SpiceGrabSequence *sequence;
>
> - sequence = g_slice_new0(SpiceGrabSequence);
> + sequence = g_new0(SpiceGrabSequence, 1);
> sequence->nkeysyms = nkeysyms;
> sequence->keysyms = g_new0(guint, nkeysyms);
> memcpy(sequence->keysyms, keysyms, sizeof(guint)*nkeysyms);
> @@ -79,7 +79,7 @@ SpiceGrabSequence
> *spice_grab_sequence_new_from_string(const gchar *str)
> int i;
> SpiceGrabSequence *sequence;
>
> - sequence = g_slice_new0(SpiceGrabSequence);
> + sequence = g_new0(SpiceGrabSequence, 1);
>
> keysymstr = g_strsplit(str, "+", 5);
>
> @@ -114,7 +114,7 @@ SpiceGrabSequence
> *spice_grab_sequence_copy(SpiceGrabSequence *srcSequence)
> {
> SpiceGrabSequence *sequence;
>
> - sequence = g_slice_dup(SpiceGrabSequence, srcSequence);
> + sequence = g_new0(SpiceGrabSequence, 1);
it's a dup, missing some copy of nkeysyms at least
> sequence->keysyms = g_new0(guint, srcSequence->nkeysyms);
> memcpy(sequence->keysyms, srcSequence->keysyms,
> sizeof(guint) * sequence->nkeysyms);
> @@ -132,7 +132,7 @@ SpiceGrabSequence
> *spice_grab_sequence_copy(SpiceGrabSequence *srcSequence)
> void spice_grab_sequence_free(SpiceGrabSequence *sequence)
> {
> g_free(sequence->keysyms);
> - g_slice_free(SpiceGrabSequence, sequence);
> + g_free(sequence);
> }
>
>
> diff --git a/src/spice-util.c b/src/spice-util.c
> index 84ed94a..fd97ee7 100644
> --- a/src/spice-util.c
> +++ b/src/spice-util.c
> @@ -153,7 +153,7 @@ static WeakHandlerCtx *
> whc_new (GObject *instance,
> GObject *observer)
> {
> - WeakHandlerCtx *ctx = g_slice_new0 (WeakHandlerCtx);
> + WeakHandlerCtx *ctx = g_new0 (WeakHandlerCtx, 1);
>
> ctx->instance = instance;
> ctx->observer = observer;
> @@ -164,7 +164,7 @@ whc_new (GObject *instance,
> static void
> whc_free (WeakHandlerCtx *ctx)
> {
> - g_slice_free (WeakHandlerCtx, ctx);
> + g_free (ctx);
> }
>
> static void observer_destroyed_cb (gpointer, GObject *);
> diff --git a/src/wocky-http-proxy.c b/src/wocky-http-proxy.c
> index ce23b0e..d84cd72 100644
> --- a/src/wocky-http-proxy.c
> +++ b/src/wocky-http-proxy.c
> @@ -285,7 +285,7 @@ free_connect_data (ConnectAsyncData *data)
> if (data->cancellable != NULL)
> g_object_unref (data->cancellable);
>
> - g_slice_free (ConnectAsyncData, data);
> + g_free (data);
> }
>
> static void
> @@ -364,7 +364,7 @@ wocky_http_proxy_connect_async (GProxy *proxy,
> callback, user_data,
> wocky_http_proxy_connect_async);
>
> - data = g_slice_new0 (ConnectAsyncData);
> + data = g_new0 (ConnectAsyncData, 1);
> if (cancellable != NULL)
> data->cancellable = g_object_ref (cancellable);
> data->simple = simple;
> --
> 2.5.0
other than that, looks ok
More information about the Spice-devel
mailing list