Surround list macros in parens in order to allow calls like this:

list_t list;
foreach(node, &list) {
  ...
}
This commit is contained in:
Mike Gerow 2015-05-15 00:35:15 -07:00 committed by Kevin Lange
parent 9cf86430ee
commit fd8c5db72a

View File

@ -46,7 +46,7 @@ node_t * list_insert_after(list_t * list, node_t * before, void * item);
void list_append_before(list_t * list, node_t * after, node_t * node);
node_t * list_insert_before(list_t * list, node_t * after, void * item);
#define foreach(i, list) for (node_t * i = list->head; i != NULL; i = i->next)
#define foreachr(i, list) for (node_t * i = list->tail; i != NULL; i = i->prev)
#define foreach(i, list) for (node_t * i = (list)->head; i != NULL; i = i->next)
#define foreachr(i, list) for (node_t * i = (list)->tail; i != NULL; i = i->prev)
#endif