summaryrefslogtreecommitdiff
path: root/lib/lists.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2013-09-16 23:57:40 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2013-09-16 23:57:40 +0200
commit6a8d3f1c1ffbd964e4d11b452c73e1ea70310af3 (patch)
treeffad2ba5c281d87ec64f3b9f419b17251ef616a6 /lib/lists.c
parentbf139664aa2ae9956b520ba4813bb6e03bf1a3e8 (diff)
BFD work in progress.
Now it compiles and mostly works.
Diffstat (limited to 'lib/lists.c')
-rw-r--r--lib/lists.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/lists.c b/lib/lists.c
index 58ffd230..d323a4b6 100644
--- a/lib/lists.c
+++ b/lib/lists.c
@@ -101,6 +101,25 @@ rem_node(node *n)
}
/**
+ * rem2_node - remove a node from a list, with cleanup
+ * @n: node to be removed
+ *
+ * Removes a node @n from the list it's linked in and resets its pointers to NULL.
+ * Useful if you want to distinguish between linked and unlinked nodes.
+ */
+LIST_INLINE void
+rem2_node(node *n)
+{
+ node *z = n->prev;
+ node *x = n->next;
+
+ z->next = x;
+ x->prev = z;
+ n->next = NULL;
+ n->prev = NULL;
+}
+
+/**
* replace_node - replace a node in a list with another one
* @old: node to be removed
* @new: node to be inserted