X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Flist.c;h=e341d45bd432e5cfe1178260eba1c276629f9b1f;hb=003ce655b7116d18c86a74c50391e54990346931;hp=227546e95f3bdbbeaa5e30c64783f0e18259d1f3;hpb=113269228827043aaca717b5fb11b055e09a4636;p=sliver-openvswitch.git diff --git a/lib/list.c b/lib/list.c index 227546e95..e341d45bd 100644 --- a/lib/list.c +++ b/lib/list.c @@ -101,6 +101,20 @@ list_moved(struct list *list) list->prev->next = list->next->prev = list; } +/* Initializes 'dst' with the contents of 'src', compensating for moving it + * around in memory. The effect is that, if 'src' was the head of a list, now + * 'dst' is the head of a list containing the same elements. */ +void +list_move(struct list *dst, struct list *src) +{ + if (!list_is_empty(src)) { + *dst = *src; + list_moved(dst); + } else { + list_init(dst); + } +} + /* Removes 'elem' from its list and returns the element that followed it. Undefined behavior if 'elem' is not in a list. */ struct list *