about summary refs log tree commit diff
path: root/src/c-list
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2022-08-16 18:25:29 +0200
committerMichael Biebl <biebl@debian.org>2022-08-16 18:25:29 +0200
commite8c0c4050b07c08cc0f34d41cdff98f2cdc1cc93 (patch)
tree79a3d9572e508d4b193ea175c8ed103b2024f727 /src/c-list
parent49ac65f875a36d7ebcbc8270cf0fc60acbb2e052 (diff)
parent0018d1f3cf71d680d7b6bceda55a5717244d8b26 (diff)
Update upstream source from tag 'upstream/1.39.90'
Update to upstream version '1.39.90'
with Debian dir 898f1bfdb7bf17595463e4195c78d8455df545e6
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
  *