]> git.mdlowis.com Git - proto/labwc.git/commitdiff
common/list: add WL_LIST_INIT() macro
authortokyo4j <hrak1529@gmail.com>
Wed, 20 Nov 2024 18:39:16 +0000 (03:39 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 21 Nov 2024 20:31:41 +0000 (20:31 +0000)
include/common/list.h

index 37d4b72f85b4f934a1cedacee8b936052742aea0..74c6911e3c76c3e7a8be8f32b61b745aca6f8772 100644 (file)
@@ -20,4 +20,13 @@ 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 */