From bda77a83f789371f303b4533a42199c2171b291b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 15 Dec 2018 11:46:34 +0100 Subject: [PATCH] tllist: cast away const in tll_{r,}foreach() This allows us to iterate const lists. --- tllist.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tllist.h b/tllist.h index ea37b4a..acd0ab4 100644 --- a/tllist.h +++ b/tllist.h @@ -82,16 +82,16 @@ * } */ #define tll_foreach(list, it) \ - for (__typeof((list).head) it = (list).head, \ - it_next = it != NULL ? it->next : NULL; \ + for (__typeof__(*(list).head) *it = (list).head, \ + *it_next = it != NULL ? it->next : NULL; \ it != NULL; \ it = it_next, \ it_next = it_next != NULL ? it_next->next : NULL) /* Same as tll_foreach(), but iterates backwards */ #define tll_rforeach(list, it) \ - for (__typeof((list).tail) it = (list).tail, \ - it_prev = it != NULL ? it->prev : NULL; \ + for (__typeof__(*(list).tail) *it = (list).tail, \ + *it_prev = it != NULL ? it->prev : NULL; \ it != NULL; \ it = it_prev, \ it_prev = it_prev != NULL ? it_prev->prev : NULL)