]> wimlib.net Git - wimlib/blobdiff - include/wimlib/list.h
update; add lzms_decompress() stub
[wimlib] / include / wimlib / list.h
index 8541d45d1a426603cb328e04dd298fd6401bdbaf..d6bd55c11013b54dadb2d0e615882058ace32e64 100644 (file)
@@ -129,6 +129,15 @@ static inline int list_empty(const struct list_head *head)
        return head->next == head;
 }
 
+/**
+ * list_is_singular - tests whether a list has just one entry.
+ * @head: the list to test.
+ */
+static inline int list_is_singular(const struct list_head *head)
+{
+       return !list_empty(head) && (head->next == head->prev);
+}
+
 static inline void __list_splice(const struct list_head *list,
                                 struct list_head *prev,
                                 struct list_head *next)
@@ -275,7 +284,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;
@@ -284,6 +303,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;