2021-07-12 13:57:08 +00:00
|
|
|
/*
|
|
|
|
* This list data structure is verbatim copy from wayland-util.h from the
|
|
|
|
* Wayland project; except that wl_ prefix has been removed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "list.h"
|
|
|
|
|
|
|
|
void list_init(struct list *list)
|
|
|
|
{
|
2021-07-12 15:55:13 +00:00
|
|
|
list->prev = list;
|
|
|
|
list->next = list;
|
2021-07-12 13:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void list_insert(struct list *list, struct list *elm)
|
|
|
|
{
|
2021-07-12 15:55:13 +00:00
|
|
|
elm->prev = list;
|
|
|
|
elm->next = list->next;
|
|
|
|
list->next = elm;
|
|
|
|
elm->next->prev = elm;
|
2021-07-12 13:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void list_remove(struct list *elm)
|
|
|
|
{
|
2021-07-12 15:55:13 +00:00
|
|
|
elm->prev->next = elm->next;
|
|
|
|
elm->next->prev = elm->prev;
|
|
|
|
elm->next = NULL;
|
|
|
|
elm->prev = NULL;
|
2021-07-12 13:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int list_empty(const struct list *list)
|
|
|
|
{
|
2021-07-12 15:55:13 +00:00
|
|
|
return list->next == list;
|
2021-07-12 13:57:08 +00:00
|
|
|
}
|