[Spice-devel] [PATCH v2 8/9] Change RedCharDevice::write_queue to GQueue

Frediano Ziglio fziglio at redhat.com
Thu Sep 15 15:58:31 UTC 2016


> 
> Change a couple more Rings to GQueue
> ---
> Changes in v2:
>  - use GQueue, not GList
> 
>  server/char-device.c | 79
>  +++++++++++++++++++++-------------------------------
>  server/char-device.h |  1 -
>  2 files changed, 32 insertions(+), 48 deletions(-)
> 
> diff --git a/server/char-device.c b/server/char-device.c
> index 957fb26..f826524 100644
> --- a/server/char-device.c
> +++ b/server/char-device.c
> @@ -50,8 +50,8 @@ struct RedCharDevicePrivate {
>      int active; /* has read/write been performed since the device was
>      started */
>      int wait_for_migrate_data;
>  
> -    Ring write_queue;
> -    Ring write_bufs_pool;
> +    GQueue *write_queue;
> +    GQueue *write_bufs_pool;
>      uint64_t cur_pool_size;
>      RedCharDeviceWriteBuffer *cur_write_buf;
>      uint8_t *cur_write_buf_pos;
....
> @@ -1195,8 +1180,8 @@ red_char_device_init(RedCharDevice *self)
>  {
>      self->priv = RED_CHAR_DEVICE_PRIVATE(self);
>  
> -    ring_init(&self->priv->write_queue);
> -    ring_init(&self->priv->write_bufs_pool);
> +    self->priv->write_queue = g_queue_new();
> +    self->priv->write_bufs_pool = g_queue_new();
>      ring_init(&self->priv->clients);
>  
>      g_signal_connect(self, "notify::sin",
>      G_CALLBACK(red_char_device_on_sin_changed), NULL);

Why not using "GQueue write_queue"/"GQueue write_bufs_pool" and g_queue_init
instead to avoid the pointer dereference every time?

Frediano


More information about the Spice-devel mailing list