mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-22 18:30:31 +01:00
util/list: Add list splicing functions
This adds functions for splicing one list into another. These have more-or-less the same API as the kernel list splicing functions. The implementation, however, was stolen from the Wayland list implementation. Reviewed-by: Mark Janes <mark.a.janes@intel.com> Reviewed-by: Rob Clark <robclark@freedesktop.org>
This commit is contained in:
parent
082f6d75ae
commit
7dac4a2889
1 changed files with 22 additions and 0 deletions
|
|
@ -116,6 +116,28 @@ static inline unsigned list_length(struct list_head *list)
|
|||
return length;
|
||||
}
|
||||
|
||||
static inline void list_splice(struct list_head *src, struct list_head *dst)
|
||||
{
|
||||
if (list_empty(src))
|
||||
return;
|
||||
|
||||
src->next->prev = dst;
|
||||
src->prev->next = dst->next;
|
||||
dst->next->prev = src->prev;
|
||||
dst->next = src->next;
|
||||
}
|
||||
|
||||
static inline void list_splicetail(struct list_head *src, struct list_head *dst)
|
||||
{
|
||||
if (list_empty(src))
|
||||
return;
|
||||
|
||||
src->prev->next = dst;
|
||||
src->next->prev = dst->prev;
|
||||
dst->prev->next = src->next;
|
||||
dst->prev = src->prev;
|
||||
}
|
||||
|
||||
static inline void list_validate(struct list_head *list)
|
||||
{
|
||||
struct list_head *node;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue