X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=com_list.h;h=074b550414a8a6bca30f28c6fbe85c5d8a66b3ff;hp=da4f3a79d9ebea846d93ad8de44daa99418da97f;hb=0dfd3a30839fefb7c1d817618354350f4efd1131;hpb=93ea3eb0edb917080adabff49424e43394a379d5 diff --git a/com_list.h b/com_list.h index da4f3a79..074b5504 100644 --- a/com_list.h +++ b/com_list.h @@ -100,6 +100,7 @@ typedef struct llist_s #define List_For_Each_Safe(pos, n, head) \ for (pos = (head)->next, n = pos->next; pos != (head); \ pos = n, n = pos->next) + /* * Iterate over a list backwards, safe against removal of list entry */ @@ -107,6 +108,7 @@ typedef struct llist_s for (pos = (head)->prev, n = pos->prev; \ pos != (head); \ pos = n, n = pos->prev) + /* * Test if the entry points to the head of the list */ @@ -117,9 +119,9 @@ typedef struct llist_s * Iterate over a list of a given type */ #define List_For_Each_Entry(pos, head, member) \ - for (pos = List_Last_Entry(head, Q_typeof(*pos), member); \ + for (pos = List_First_Entry(head, Q_typeof(*pos), member); \ !List_Entry_Is_Head(pos, head, member); \ - pos = List_Prev_Entry(pos, member)) + pos = List_Next_Entry(pos, member)) /* * Iterate over a list of a given type backwards @@ -173,6 +175,7 @@ typedef struct llist_s n = List_Next_Entry(pos, member); \ !List_Entry_Is_Head(pos, head, member); \ pos = n, n = List_Next_Entry(n, member)) + /* * Continue iteration over a list of a given type, after the current position, safe against removal of list entry */ @@ -190,7 +193,6 @@ typedef struct llist_s !List_Entry_Is_Head(pos, head, member); \ pos = n, n = List_Next_Entry(n, member)) - /* * Iterate over a list of a given type backwards, safe against removal of list entry */ @@ -217,7 +219,7 @@ static inline qbool List_Is_Empty(const llist_t *list) */ static inline void List_Create(llist_t *list) { - list->next = list->prev = NULL; + list->next = list->prev = list; } /*