[Spice-devel] [PATCH 04/26] ring: add RING_FOREACH{, _SAFE, _REVERSED}

Marc-André Lureau marcandre.lureau at gmail.com
Mon Feb 14 17:44:09 PST 2011


ack

On Fri, Feb 11, 2011 at 6:48 PM, Alon Levy <alevy at redhat.com> wrote:
> ---
>  common/ring.h |   19 +++++++++++++++++++
>  1 files changed, 19 insertions(+), 0 deletions(-)
>
> diff --git a/common/ring.h b/common/ring.h
> index defa1ed..a841422 100644
> --- a/common/ring.h
> +++ b/common/ring.h
> @@ -129,5 +129,24 @@ static inline RingItem *ring_prev(Ring *ring, RingItem *pos)
>     return (ret == ring) ? NULL : ret;
>  }
>
> +#define RING_FOREACH_SAFE(var, next, ring)                    \
> +    for ((var) = ring_get_head(ring),                         \
> +         (next) = (var) ? ring_next(ring, (var)) : NULL;      \
> +            (var);                                            \
> +            (var) = (next),                                   \
> +            (next) = (var) ? ring_next(ring, (var)) : NULL)
> +
> +
> +#define RING_FOREACH(var, ring)                 \
> +    for ((var) = ring_get_head(ring);           \
> +            (var);                              \
> +            (var) = ring_next(ring, var))
> +
> +#define RING_FOREACH_REVERSED(var, ring)        \
> +    for ((var) = ring_get_tail(ring);           \
> +            (var);                              \
> +            (var) = ring_prev(ring, var))
> +
> +
>  #endif
>
> --
> 1.7.4
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>



-- 
Marc-André Lureau


More information about the Spice-devel mailing list