X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Futil%2Flist.h;h=e8a99ac8e008c3103eee2a45c00d2c8d5321714d;hb=8dd985351675c0d31f6a3f757727b92b71c711ff;hp=f0dec5da60874c7cf9e6028589e9d1f03697816b;hpb=ff8895ba5606372f368917b97b8c4380bb822234;p=mesa.git diff --git a/src/util/list.h b/src/util/list.h index f0dec5da608..e8a99ac8e00 100644 --- a/src/util/list.h +++ b/src/util/list.h @@ -71,12 +71,18 @@ static inline void list_addtail(struct list_head *item, struct list_head *list) list->prev = item; } +static inline bool list_empty(struct list_head *list); + static inline void list_replace(struct list_head *from, struct list_head *to) { - to->prev = from->prev; - to->next = from->next; - from->next->prev = to; - from->prev->next = to; + if (list_empty(from)) { + list_inithead(to); + } else { + to->prev = from->prev; + to->next = from->next; + from->next->prev = to; + from->prev->next = to; + } } static inline void list_del(struct list_head *item)