+/**
+ * Remove a node @n and mark it as unlinked by setting the previous and next pointers to NULL.
+ **/
+static inline void clist_unlink(cnode *n)
+{
+ clist_remove(n);
+ n->prev = n->next = NULL;
+}
+
+/**
+ * Remove the first node on @l and mark it as unlinked.
+ * Return the pointer to that node or NULL.
+ **/
+static inline void *clist_unlink_head(clist *l)
+{
+ cnode *n = clist_head(l);
+ if (n)
+ clist_unlink(n);
+ return n;
+}
+
+/**
+ * Remove the last node on @l and mark it as unlinked.
+ * Return the pointer to that node or NULL.
+ **/
+static inline void *clist_unlink_tail(clist *l)
+{
+ cnode *n = clist_tail(l);
+ if (n)
+ clist_unlink(n);
+ return n;
+}
+
+/**
+ * Check if a node is linked a list. Unlinked nodes are recognized by having their
+ * previous and next pointers equal to NULL. Returns 0 or 1.
+ *
+ * Nodes initialized to all zeroes are unlinked, inserting a node anywhere in a list
+ * makes it linked. Normal removal functions like clist_remove() do not mark nodes
+ * as unlinked, you need to call clist_unlink() instead.
+ **/
+static inline int clist_is_linked(cnode *n)
+{
+ return !!n->next;
+}
+