util: add a LIST_INIT macro

Necessary for the case where we need a compile-time initialized list.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/984>
This commit is contained in:
Peter Hutterer 2024-03-14 08:49:33 +10:00 committed by Marge Bot
parent 3a935507ae
commit 4935e52652
2 changed files with 3 additions and 2 deletions

View file

@ -34,8 +34,7 @@
void
list_init(struct list *list)
{
list->prev = list;
list->next = list;
*list = LIST_INIT(*list);
}
void

View file

@ -62,6 +62,8 @@ struct list {
struct list *next;
};
#define LIST_INIT(l) (struct list){ .prev = &(l), .next = &(l) }
/**
* Initialize a list head. This function *must* be called once for each list
* head. This function *must not* be called for a node to be added to a