X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Flist.h;h=ff39710b1dec75761b98a66e2605f824aceaa5a4;hp=889097b5acf36521157178f9d1e0995fce306bcc;hb=3f9b53a4a214a254bb27ed30994faf2a0fd12375;hpb=394c5bd3292c0f3168416c0a5f25989e557b3cfc diff --git a/src/list.h b/src/list.h index 889097b5..ff39710b 100644 --- a/src/list.h +++ b/src/list.h @@ -145,6 +145,24 @@ static inline void list_splice(const struct list_head *list, __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.