]> wimlib.net Git - wimlib/blobdiff - src/list.h
write.c, lookup table.c: cleanup
[wimlib] / src / list.h
index 889097b5acf36521157178f9d1e0995fce306bcc..ff39710b1dec75761b98a66e2605f824aceaa5a4 100644 (file)
@@ -145,6 +145,24 @@ static inline void list_splice(const struct list_head *list,
                __list_splice(list, head, head->next);
 }
 
                __list_splice(list, head, head->next);
 }
 
+/* Move the entire list @old to the list @new, overwriting it. */
+static inline void list_transfer(struct list_head *old,
+                                struct list_head *new)
+{
+       struct list_head *prev, *next;
+
+       if (list_empty(old)) {
+               INIT_LIST_HEAD(new);
+       } else {
+               prev = old->prev;
+               next = old->next;
+               new->next = next;
+               new->prev = prev;
+               prev->next = new;
+               next->prev = new;
+       }
+}
+
 /**
  * list_splice_tail - join two lists, each list being a queue
  * @list: the new list to add.
 /**
  * list_splice_tail - join two lists, each list being a queue
  * @list: the new list to add.