mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-24 21:05:40 +02:00
tllist: cast away const in tll_{r,}foreach()
This allows us to iterate const lists.
This commit is contained in:
parent
ee156c8dc7
commit
bda77a83f7
1 changed files with 4 additions and 4 deletions
8
tllist.h
8
tllist.h
|
@ -82,16 +82,16 @@
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
#define tll_foreach(list, it) \
|
#define tll_foreach(list, it) \
|
||||||
for (__typeof((list).head) it = (list).head, \
|
for (__typeof__(*(list).head) *it = (list).head, \
|
||||||
it_next = it != NULL ? it->next : NULL; \
|
*it_next = it != NULL ? it->next : NULL; \
|
||||||
it != NULL; \
|
it != NULL; \
|
||||||
it = it_next, \
|
it = it_next, \
|
||||||
it_next = it_next != NULL ? it_next->next : NULL)
|
it_next = it_next != NULL ? it_next->next : NULL)
|
||||||
|
|
||||||
/* Same as tll_foreach(), but iterates backwards */
|
/* Same as tll_foreach(), but iterates backwards */
|
||||||
#define tll_rforeach(list, it) \
|
#define tll_rforeach(list, it) \
|
||||||
for (__typeof((list).tail) it = (list).tail, \
|
for (__typeof__(*(list).tail) *it = (list).tail, \
|
||||||
it_prev = it != NULL ? it->prev : NULL; \
|
*it_prev = it != NULL ? it->prev : NULL; \
|
||||||
it != NULL; \
|
it != NULL; \
|
||||||
it = it_prev, \
|
it = it_prev, \
|
||||||
it_prev = it_prev != NULL ? it_prev->prev : NULL)
|
it_prev = it_prev != NULL ? it_prev->prev : NULL)
|
||||||
|
|
Loading…
Add table
Reference in a new issue