]> git.mdlowis.com Git - proto/labwc.git/commitdiff
common: add wl_list_append()
authorJohan Malm <jgm323@gmail.com>
Tue, 4 Oct 2022 21:04:09 +0000 (22:04 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Wed, 5 Oct 2022 18:50:36 +0000 (19:50 +0100)
include/common/list.h [new file with mode: 0644]

diff --git a/include/common/list.h b/include/common/list.h
new file mode 100644 (file)
index 0000000..a56d66a
--- /dev/null
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#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);
+}