From b59d9c537bfddf6d1aa85b61e2f8b25163f6f0ef Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 6 Dec 2013 14:35:22 +1000 Subject: [PATCH] util: add ARRAY_FOR_EACH helper Requires c99, but that's the future. Signed-off-by: Peter Hutterer --- src/libinput-util.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libinput-util.h b/src/libinput-util.h index 45549e05..381a0d44 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -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