array: add foreach() statement

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-04-09 17:16:08 +02:00
parent 82dd52ad69
commit e145afec53
1 changed files with 5 additions and 0 deletions

View File

@ -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); \