This commit is contained in:
taiyu 2015-08-31 08:29:25 -07:00
parent 4d9b05e649
commit 7dcca7a4b4
2 changed files with 65 additions and 87 deletions

View file

@ -14,4 +14,13 @@ void list_insert(list_t *list, int index, void *item);
void list_del(list_t *list, int index);
void list_cat(list_t *list, list_t *source);
// ITEM must be a pointer, LIST is list_t*
// ITEM will be NULL after empty list
#define list_for(ITEM, LIST) \
ITEM = LIST->length ? LIST->items[0] : NULL; \
for(int list_it = 0, list_len = LIST->length; \
list_it < list_len; \
ITEM = LIST->items[++list_it])
#endif