Fix foreach macro

Fixes support of break/continue statement

Signed-off-by: Mariusz Ceier <mceier@gmail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Mariusz Ceier 2009-04-29 20:37:45 +02:00 committed by Julien Danjou
parent 505245a5ff
commit 7010ffd164
1 changed files with 5 additions and 3 deletions

View File

@ -34,9 +34,11 @@
#define foreach(var, array) \ #define foreach(var, array) \
for(int __foreach_index_##var = 0; \ for(int __foreach_index_##var = 0; \
__foreach_index_##var < (array).len; \ __foreach_index_##var < (array).len; \
__foreach_index_##var++) \ __foreach_index_##var = (array).len) \
for(typeof((array).tab) var = &(array).tab[__foreach_index_##var]; \ for(typeof((array).tab) var = &(array).tab[__foreach_index_##var]; \
var; var = NULL) (__foreach_index_##var < (array).len) && \
(var = &(array).tab[__foreach_index_##var]); \
++__foreach_index_##var)
#define ARRAY_FUNCS(type_t, pfx, dtor) \ #define ARRAY_FUNCS(type_t, pfx, dtor) \
static inline pfx##_array_t * pfx##_array_new(void) { \ static inline pfx##_array_t * pfx##_array_new(void) { \