summaryrefslogtreecommitdiff
path: root/lib/lists.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lists.c')
-rw-r--r--lib/lists.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/lists.c b/lib/lists.c
index 200576cf..cabfddba 100644
--- a/lib/lists.c
+++ b/lib/lists.c
@@ -26,7 +26,7 @@
#define _BIRD_LISTS_C_
-#include "nest/bird.h"
+#include "lib/birdlib.h"
#include "lib/lists.h"
LIST_INLINE int
@@ -37,9 +37,10 @@ check_list(list *l, node *n)
ASSERT_DIE(n);
ASSERT_DIE(n->prev);
- do { n = n->prev; } while (n->prev);
+ node *nn = n;
+ do { nn = nn->prev; } while (nn->prev);
- l = SKIP_BACK(list, head_node, n);
+ l = SKIP_BACK(list, head_node, nn);
}
int seen = 0;
@@ -120,7 +121,7 @@ add_head(list *l, node *n)
LIST_INLINE void
insert_node(node *n, node *after)
{
- EXPENSIVE_CHECK(check_list(l, after));
+ EXPENSIVE_CHECK((after->prev == NULL) || check_list(NULL, after));
ASSUME(n->prev == NULL);
ASSUME(n->next == NULL);
@@ -141,7 +142,7 @@ insert_node(node *n, node *after)
LIST_INLINE void
rem_node(node *n)
{
- EXPENSIVE_CHECK(check_list(NULL, n));
+ EXPENSIVE_CHECK((n->prev == n) && (n->next == n) || check_list(NULL, n));
node *z = n->prev;
node *x = n->next;