]> wimlib.net Git - wimlib/blobdiff - include/wimlib/list.h
hardlink.c: Fix some error paths
[wimlib] / include / wimlib / list.h
index ff4074286fb3659600734f255019854d05a19851..763178ba71f16fb596e3ecfcde22a03ca3f34ead 100644 (file)
@@ -110,6 +110,16 @@ static inline void list_del(struct list_head *entry)
        __list_del(entry->prev, entry->next);
 }
 
+/**
+ * list_del_init - deletes entry from list and reinitialize it.
+ * @entry: the element to delete from the list.
+ */
+static inline void list_del_init(struct list_head *entry)
+{
+       list_del(entry);
+       INIT_LIST_HEAD(entry);
+}
+
 /**
  * list_empty - tests whether a list is empty
  * @head: the list to test.
@@ -265,7 +275,17 @@ static inline void INIT_HLIST_NODE(struct hlist_node *h)
        h->pprev = NULL;
 }
 
-static inline void hlist_del(struct hlist_node *n)
+static inline int hlist_unhashed(const struct hlist_node *h)
+{
+       return !h->pprev;
+}
+
+static inline int hlist_empty(const struct hlist_head *h)
+{
+       return !h->first;
+}
+
+static inline void __hlist_del(struct hlist_node *n)
 {
        struct hlist_node *next = n->next;
        struct hlist_node **pprev = n->pprev;
@@ -274,6 +294,23 @@ static inline void hlist_del(struct hlist_node *n)
                next->pprev = pprev;
 }
 
+static inline void hlist_del(struct hlist_node *n)
+{
+       __hlist_del(n);
+#if 0
+       n->next = LIST_POISON1;
+       n->pprev = LIST_POISON2;
+#endif
+}
+
+static inline void hlist_del_init(struct hlist_node *n)
+{
+       if (!hlist_unhashed(n)) {
+               __hlist_del(n);
+               INIT_HLIST_NODE(n);
+       }
+}
+
 static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
 {
        struct hlist_node *first = h->first;