mirror of
https://github.com/swaywm/sway.git
synced 2026-04-26 06:46:26 -04:00
Introduce list_for_each utility for iterating over list_t
This commit is contained in:
parent
b3f08597cd
commit
2438a024df
1 changed files with 5 additions and 0 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue