diff --git a/include/list.h b/include/list.h index 895f6cc01..ce23f1eed 100644 --- a/include/list.h +++ b/include/list.h @@ -27,6 +27,11 @@ void list_swap(list_t *list, int src, int dest); // move item to end of list void list_move_to_end(list_t *list, void *item); +#define list_for_each(e, list) \ + for (__typeof__(e) *p = (__typeof__(e) *) (list)->items, (e) = *p; \ + (void **) p < ((list)->items + (list)->length); \ + p++, (e) = *p) + /* Calls `free` for each item in the list, then frees the list. * Do not use this to free lists of primitives or items that require more * complicated deallocation code.