<p dir="ltr"><br>
On Jul 2, 2016 9:52 AM, "Rob Clark" <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>> wrote:<br>
><br>
> Before, it would happily copy list_head next/prev (ie. pointer to the<br>
> *from* list_head), leaving things in a confused state and causing much<br>
> mayhem.</p>
<p dir="ltr">Heh, so it would... Thanks for fixing that.</p>
<p dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></p>
<p dir="ltr">> Signed-off-by: Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>><br>
> ---<br>
> src/util/list.h | 14 ++++++++++----<br>
> 1 file changed, 10 insertions(+), 4 deletions(-)<br>
><br>
> diff --git a/src/util/list.h b/src/util/list.h<br>
> index f0dec5d..e8a99ac 100644<br>
> --- a/src/util/list.h<br>
> +++ b/src/util/list.h<br>
> @@ -71,12 +71,18 @@ static inline void list_addtail(struct list_head *item, struct list_head *list)<br>
> list->prev = item;<br>
> }<br>
><br>
> +static inline bool list_empty(struct list_head *list);<br>
> +<br>
> static inline void list_replace(struct list_head *from, struct list_head *to)<br>
> {<br>
> - to->prev = from->prev;<br>
> - to->next = from->next;<br>
> - from->next->prev = to;<br>
> - from->prev->next = to;<br>
> + if (list_empty(from)) {<br>
> + list_inithead(to);<br>
> + } else {<br>
> + to->prev = from->prev;<br>
> + to->next = from->next;<br>
> + from->next->prev = to;<br>
> + from->prev->next = to;<br>
> + }<br>
> }<br>
><br>
> static inline void list_del(struct list_head *item)<br>
> --<br>
> 2.7.4<br>
><br>
</p>