src/list.c

changeset 664
af5bf4603a5d
parent 655
7340c4255f1f
child 666
b5dd654deb3b
--- a/src/list.c	Sun Mar 05 10:55:32 2023 +0100
+++ b/src/list.c	Tue Mar 14 20:25:24 2023 +0100
@@ -95,6 +95,10 @@
     return list->climpl->remove(list, index);
 }
 
+static void cx_pl_clear(struct cx_list_s *list) {
+    list->climpl->clear(list);
+}
+
 static int cx_pl_swap(
         struct cx_list_s *list,
         size_t i,
@@ -164,6 +168,7 @@
         cx_pl_insert_array,
         cx_pl_insert_iter,
         cx_pl_remove,
+        cx_pl_clear,
         cx_pl_swap,
         cx_pl_at,
         cx_pl_find,
@@ -192,6 +197,24 @@
 
 // </editor-fold>
 
+void cx_list_invoke_destructor(
+        CxList const *list,
+        void *elem
+) {
+    switch (list->content_destructor_type) {
+        case CX_DESTRUCTOR_SIMPLE: {
+            list->simple_destructor(elem);
+            break;
+        }
+        case CX_DESTRUCTOR_ADVANCED: {
+            list->advanced_destructor.func(list->advanced_destructor.data, elem);
+            break;
+        }
+        case CX_DESTRUCTOR_NONE:
+            break; // nothing
+    }
+}
+
 void cxListDestroy(CxList *list) {
     switch (list->content_destructor_type) {
         case CX_DESTRUCTOR_SIMPLE: {

mercurial