X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=com_list.h;h=074b550414a8a6bca30f28c6fbe85c5d8a66b3ff;hp=cf05f541277a4037880d7959c6cc394f64c92ff4;hb=00b6d96fd1220b1df82036c445389ae19a08709e;hpb=7d1f3e96e8b6ccc7fda2c4f95bd137fc52a0b3ae diff --git a/com_list.h b/com_list.h index cf05f541..074b5504 100644 --- a/com_list.h +++ b/com_list.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2020 David "Cloudwalk" Knapp +Copyright (C) 2020-2021 David Knapp (Cloudwalk) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -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; } /*