[PATCH libinput 03/10] util: add a list_append()

Peter Hutterer peter.hutterer at who-t.net
Mon May 28 08:08:29 UTC 2018


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/libinput-util.c | 14 ++++++++++++++
 src/libinput-util.h |  1 +
 2 files changed, 15 insertions(+)

diff --git a/src/libinput-util.c b/src/libinput-util.c
index 80ed489a..d8878f6a 100644
--- a/src/libinput-util.c
+++ b/src/libinput-util.c
@@ -61,6 +61,20 @@ list_insert(struct list *list, struct list *elm)
 	elm->next->prev = elm;
 }
 
+void
+list_append(struct list *list, struct list *elm)
+{
+	assert((list->next != NULL && list->prev != NULL) ||
+	       !"list->next|prev is NULL, possibly missing list_init()");
+	assert(((elm->next == NULL && elm->prev == NULL) || list_empty(elm)) ||
+	       !"elm->next|prev is not NULL, list node used twice?");
+
+	elm->next = list;
+	elm->prev = list->prev;
+	list->prev = elm;
+	elm->prev->next = elm;
+}
+
 void
 list_remove(struct list *elm)
 {
diff --git a/src/libinput-util.h b/src/libinput-util.h
index c6759718..5d16b973 100644
--- a/src/libinput-util.h
+++ b/src/libinput-util.h
@@ -86,6 +86,7 @@ struct list {
 
 void list_init(struct list *list);
 void list_insert(struct list *list, struct list *elm);
+void list_append(struct list *list, struct list *elm);
 void list_remove(struct list *elm);
 bool list_empty(const struct list *list);
 
-- 
2.14.3



More information about the wayland-devel mailing list