ucx/list.c

changeset 101
7b3a3130be44
parent 49
2f71f4ee247a
--- a/ucx/list.c	Thu Dec 12 20:01:43 2024 +0100
+++ b/ucx/list.c	Mon Jan 06 22:22:55 2025 +0100
@@ -59,7 +59,7 @@
 }
 
 static void cx_pl_destructor(struct cx_list_s *list) {
-    list->climpl->destructor(list);
+    list->climpl->deallocate(list);
 }
 
 static int cx_pl_insert_element(
@@ -99,11 +99,13 @@
     return list->climpl->insert_iter(iter, &elem, prepend);
 }
 
-static int cx_pl_remove(
+static size_t cx_pl_remove(
         struct cx_list_s *list,
-        size_t index
+        size_t index,
+        size_t num,
+        void *targetbuf
 ) {
-    return list->climpl->remove(list, index);
+    return list->climpl->remove(list, index, num, targetbuf);
 }
 
 static void cx_pl_clear(struct cx_list_s *list) {
@@ -210,33 +212,33 @@
 
 // <editor-fold desc="empty list implementation">
 
-static void cx_emptyl_noop(__attribute__((__unused__)) CxList *list) {
+static void cx_emptyl_noop(cx_attr_unused CxList *list) {
     // this is a noop, but MUST be implemented
 }
 
 static void *cx_emptyl_at(
-        __attribute__((__unused__)) const struct cx_list_s *list,
-        __attribute__((__unused__)) size_t index
+        cx_attr_unused const struct cx_list_s *list,
+        cx_attr_unused size_t index
 ) {
     return NULL;
 }
 
 static ssize_t cx_emptyl_find_remove(
-        __attribute__((__unused__)) struct cx_list_s *list,
-        __attribute__((__unused__)) const void *elem,
-        __attribute__((__unused__)) bool remove
+        cx_attr_unused struct cx_list_s *list,
+        cx_attr_unused const void *elem,
+        cx_attr_unused bool remove
 ) {
     return -1;
 }
 
-static bool cx_emptyl_iter_valid(__attribute__((__unused__)) const void *iter) {
+static bool cx_emptyl_iter_valid(cx_attr_unused const void *iter) {
     return false;
 }
 
 static CxIterator cx_emptyl_iterator(
         const struct cx_list_s *list,
         size_t index,
-        __attribute__((__unused__)) bool backwards
+        cx_attr_unused bool backwards
 ) {
     CxIterator iter = {0};
     iter.src_handle.c = list;
@@ -295,10 +297,9 @@
     const char *src = data;
     size_t i = 0;
     for (; i < n; i++) {
-        if (0 != invoke_list_func(insert_element,
-                                  list, index + i, src + (i * elem_size))) {
-            return i;
-        }
+        if (0 != invoke_list_func(
+            insert_element, list, index + i,
+            src + (i * elem_size))) return i;
     }
     return i;
 }
@@ -343,9 +344,8 @@
 
         // insert the elements at location si
         if (ins == 1) {
-            if (0 != invoke_list_func(insert_element,
-                                      list, di, src))
-                return inserted;
+            if (0 != invoke_list_func(
+                insert_element, list, di, src)) return inserted;
         } else {
             size_t r = invoke_list_func(insert_array, list, di, src, ins);
             if (r < ins) return inserted + r;
@@ -417,10 +417,6 @@
     return 0;
 }
 
-void cxListDestroy(CxList *list) {
-    list->cl->destructor(list);
-}
-
 int cxListCompare(
         const CxList *list,
         const CxList *other
@@ -485,3 +481,8 @@
     it.base.mutating = true;
     return it;
 }
+
+void cxListFree(CxList *list) {
+    if (list == NULL) return;
+    list->cl->deallocate(list);
+}

mercurial