ensure links only belong to 1 list

also some small documentation changes.
This commit is contained in:
2026-01-14 10:41:54 -05:00
parent e498c821bf
commit 4db7dfeb5d
3 changed files with 18 additions and 0 deletions

View File

@@ -47,9 +47,13 @@ static inline ni_list_node* ni_list__get_back(ni_list* l) {
/* Iter Helpers */
// helper macro for element traversal, ordering of operations may cause seg faults
// generally just don't remove 'it', this causes it->next on the next loop to segfault
#define NI_LIST__FOREACH(lptr) \
for (ni_list_node* it = (lptr)->head.next; it != &(lptr)->head; it = it->next)
// helper macro for element traversal, that also makes a copy of it in tmp
// useful for removing/moving the current node (it)
#define NI_LIST_FOREACH_SAFE(tmp, lptr) \
for (ni_list_node* it = (lptr)->head.next, *tmp = it->next; \
it != &(lptr)->head; \