about summary refs log tree commit diff
path: root/src/c-list
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2022-10-04 00:56:46 +0200
committerMichael Biebl <biebl@debian.org>2022-10-04 00:56:46 +0200
commit3612e6355f3f40d264ec4657547761069baa5430 (patch)
tree768e4f5b37b66f540dd7030aa2eaff2ac7bb0168 /src/c-list
parent7e9f00a3be8f65535e6620b344443ec4d403212b (diff)
parent6f7fcde10e47d8af865af336becf1fd8a446e62e (diff)
Merge tag 'debian/1.40.0-1' into debian/bullseye-backports
network-manager Debian release 1.40.0-1
Diffstat (limited to 'src/c-list')
-rw-r--r--src/c-list/src/c-list.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/c-list/src/c-list.h b/src/c-list/src/c-list.h
index 69de0b31..711b54d6 100644
--- a/src/c-list/src/c-list.h
+++ b/src/c-list/src/c-list.h
@@ -260,6 +260,31 @@ static inline void c_list_splice(CList *target, CList *source) {
 }
 
 /**
+ * c_list_split() - split one list in two
+ * @source:     the list to split
+ * @where:      new starting element of newlist
+ * @target:     new list
+ *
+ * This splits @source in two. All elements following @where (including @where)
+ * are moved to @target, replacing any old list. If @where points to @source
+ * (i.e., the end of the list), @target will be empty.
+ */
+static inline void c_list_split(CList *source, CList *where, CList *target) {
+        if (where == source) {
+                *target = (CList)C_LIST_INIT(*target);
+        } else {
+                target->next = where;
+                target->prev = source->prev;
+
+                where->prev->next = source;
+                source->prev = where->prev;
+
+                where->prev = target;
+                target->prev->next = target;
+        }
+}
+
+/**
  * c_list_first() - return pointer to first element, or NULL if empty
  * @list:               list to operate on, or NULL
  *