From 6c834f997d337a4d9c615e1d155963018a3cc3fa Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 6 May 2014 16:20:44 +0200 Subject: add foreach_linked_list_node MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libmdsserver/linked-list.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/libmdsserver/linked-list.h') diff --git a/src/libmdsserver/linked-list.h b/src/libmdsserver/linked-list.h index 69298ca..30808fc 100644 --- a/src/libmdsserver/linked-list.h +++ b/src/libmdsserver/linked-list.h @@ -266,6 +266,15 @@ void linked_list_marshal(const linked_list_t* restrict this, char* restrict data */ int linked_list_unmarshal(linked_list_t* restrict this, char* restrict data); +/** + * Wrapper for `for` keyword that iterates over each element in a linked list + * + * @param list:linked_list_t The linked list + * @param node:ssize_t The variable to store the node in at each iteration + */ +#define foreach_linked_list_node(list, node) \ + for (node = list.edge; (node = list.next[node]) != list.edge;) + #endif -- cgit v1.2.3-70-g09d2