From e145afec53d639c264dbfa0b538e485b749df8a9 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 9 Apr 2009 17:16:08 +0200 Subject: [PATCH] array: add foreach() statement Signed-off-by: Julien Danjou --- common/array.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/array.h b/common/array.h index fcda00d9c..394790170 100644 --- a/common/array.h +++ b/common/array.h @@ -30,6 +30,11 @@ int len, size; \ } pfx##_array_t; +#define foreach(var, array) \ + for(typeof((array).tab) var = (array).tab; \ + var < (array).tab + (array).len; \ + var++) + #define ARRAY_FUNCS(type_t, pfx, dtor) \ static inline pfx##_array_t * pfx##_array_new(void) { \ return p_new(pfx##_array_t, 1); \