File: list.h

package info (click to toggle)
labwc 0.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,980 kB
  • sloc: ansic: 34,416; perl: 5,836; xml: 875; sh: 162; python: 131; makefile: 12
file content (32 lines) | stat: -rw-r--r-- 1,064 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_LIST_H
#define LABWC_LIST_H
#include <wayland-server-core.h>

/**
 * wl_list_append() - add a new element to the end of a list
 * @list: list head to add it before
 * @elm: new element to be added (link of the containing struct to be precise)
 *
 * Note: In labwc, most lists are queues where we want to add new elements to
 * the end of the list. As wl_list_insert() adds elements at the front of the
 * list (like a stack) - without this helper-function - we have to use
 * wl_list_insert(list.prev, element) which is verbose and not intuitive to
 * anyone new to this API.
 */
static inline void
wl_list_append(struct wl_list *list, struct wl_list *elm)
{
	wl_list_insert(list->prev, elm);
}

/**
 * WL_LIST_INIT() - initialize a list when defining it
 * @head: pointer to the head of the list to be initialized
 *
 * For example, this can be used like this:
 * static struct wl_list list = WL_LIST_INIT(&list);
 */
#define WL_LIST_INIT(head) {.prev = (head), .next = (head)}

#endif /* LABWC_LIST_H */