[Spice-devel] [PATCH spice-gtk 03/10] display: replace ring with hashtable

Uri Lublin uril at redhat.com
Mon Sep 9 00:58:53 PDT 2013


Hi Marc-Andre,

See my comment below.

On 09/08/2013 09:59 PM, Marc-André Lureau wrote:
> diff --git a/gtk/channel-display.c b/gtk/channel-display.c
> index eab1742..7a66558 100644
> --- a/gtk/channel-display.c
> +++ b/gtk/channel-display.c
>
> @@ -705,7 +706,7 @@ static void spice_display_channel_init(SpiceDisplayChannel *channel)
>   
>       c = channel->priv = SPICE_DISPLAY_CHANNEL_GET_PRIVATE(channel);
>   
> -    ring_init(&c->surfaces);
> +    c->surfaces = g_hash_table_new(NULL, NULL);
>       c->image_cache.ops = &image_cache_ops;
>       c->palette_cache.ops = &palette_cache_ops;
>       c->image_surfaces.ops = &image_surfaces_ops;
> @@ -740,7 +741,8 @@ static int create_canvas(SpiceChannel *channel, display_surface *surface)
>               }
>   
>               emit_main_context(channel, SPICE_DISPLAY_PRIMARY_DESTROY);
> -            ring_remove(&primary->link);
> +
> +            g_hash_table_remove(c->surfaces, 0);

Use primary->surface_id (instead of 0) as key:
g_hash_table_remove(c->surfaces, GINT_TO_POINTER(primary->surface_id))

Thanks,
     Uri.
>               destroy_canvas(primary);
>               free(primary);
>           }
> @@ -792,7 +794,7 @@ static int create_canvas(SpiceChannel *channel, display_surface *surface)
>                                                surface->zlib_decoder);
>   
>       g_return_val_if_fail(surface->canvas != NULL, 0);
> -    ring_add(&c->surfaces, &surface->link);
> +    g_hash_table_insert(c->surfaces, GINT_TO_POINTER(surface->surface_id), surface);
>   
>       if (surface->primary) {
>           emit_main_context(channel, SPICE_DISPLAY_PRIMARY_CREATE,
>
> @@ -1792,7 +1783,7 @@ static void display_handle_surface_destroy(SpiceChannel *channel, SpiceMsgIn *in
>           emit_main_context(channel, SPICE_DISPLAY_PRIMARY_DESTROY);
>       }
>   
> -    ring_remove(&surface->link);
> +    g_hash_table_remove(c->surfaces, GINT_TO_POINTER(surface->surface_id));
>       destroy_canvas(surface);
>       free(surface);
>   }



More information about the Spice-devel mailing list