[Spice-devel] [RFC spice-common 2/2] ring: allow testing if a ring is initialized or not

Frediano Ziglio fziglio at redhat.com
Thu Jun 27 08:39:16 UTC 2019


> 
> ---
>  common/ring.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/common/ring.h b/common/ring.h
> index 5054193..d5eadea 100644
> --- a/common/ring.h
> +++ b/common/ring.h
> @@ -50,6 +50,11 @@ static inline int ring_is_empty(Ring *ring)
>      return ring == ring->next;
>  }
> 
> +static inline int ring_is_initialized(Ring *ring)
> +{
> +    return ring->next != NULL && ring->prev != NULL;
> +}
> +
>  static inline void ring_add(Ring *ring, RingItem *item)
>  {
>      spice_assert(ring->next != NULL && ring->prev != NULL);

Hi,
  all variables should be initialized, if not I would
abort().
If you want instead to check if the Ring contains element
you can use ring_is_empty.

Frediano


More information about the Spice-devel mailing list