about summary refs log tree commit diff
path: root/shared/c-list
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2018-09-08 17:44:52 +0200
committerMichael Biebl <biebl@debian.org>2018-09-08 17:44:52 +0200
commitd8cad4490d54acb162ad218a8a682ab379bb8bcc (patch)
tree140abd545d62a1b0144be27c93ad8edb021e4311 /shared/c-list
parente3bc109cd0eb97346c448f591af518d85dbee21b (diff)
parent8f7a3cbbdd0c0a48277c341dd3a8ec8743ae9735 (diff)
Update upstream source from tag 'upstream/1.13.90'
Update to upstream version '1.13.90'
with Debian dir d7d3d98e1240df49343a72511602da7099232e10
Diffstat (limited to 'shared/c-list')
-rw-r--r--shared/c-list/src/c-list.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/shared/c-list/src/c-list.h b/shared/c-list/src/c-list.h
index ff434d8d..3d44e330 100644
--- a/shared/c-list/src/c-list.h
+++ b/shared/c-list/src/c-list.h
@@ -367,6 +367,25 @@ static inline CList *c_list_last(CList *list) {
              _safe = c_list_entry((_safe)->_m.next, __typeof__(*_iter), _m))    \
 
 /**
+ * c_list_flush() - flush all entries from a list
+ * @list:               list to flush
+ *
+ * This unlinks all entries from the given list @list and reinitializes their
+ * link-nodes via C_LIST_INIT().
+ *
+ * Note that the entries are not modified in any other way, nor is their memory
+ * released. This function just unlinks them and resets all the list nodes. It
+ * is particularly useful with temporary lists on the stack in combination with
+ * the GCC-extension __attribute__((__cleanup__(arg))).
+ */
+static inline void c_list_flush(CList *list) {
+        CList *iter, *safe;
+
+        c_list_for_each_safe_unlink(iter, safe, list)
+                /* empty */ ;
+}
+
+/**
  * c_list_length() - return number of linked entries, excluding the head
  * @list:               list to operate on
  *