util: add ARRAY_FOR_EACH helper

Requires c99, but that's the future.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2013-12-06 14:35:22 +10:00 committed by Jonas Ådahl
parent 95c6ac638f
commit b59d9c537b

View file

@ -70,6 +70,8 @@ int list_empty(const struct list *list);
tmp = container_of(pos->member.next, tmp, member))
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
#define ARRAY_FOR_EACH(_arr, _elem) \
for (int i = 0; (_elem = &_arr[i]) && i < ARRAY_LENGTH(_arr); i++)
/*
* This fixed point implementation is a verbatim copy from wayland-util.h from