src/list.c

changeset 1287
3a3ffc27813f
parent 1163
68ff0839bc6a
--- a/src/list.c	Sat Apr 12 21:32:31 2025 +0200
+++ b/src/list.c	Sun Apr 13 11:09:05 2025 +0200
@@ -494,3 +494,24 @@
     if (list == NULL) return;
     list->cl->deallocate(list);
 }
+
+int cxListSet(
+        CxList *list,
+        size_t index,
+        const void *elem
+) {
+    if (index >= list->collection.size) {
+        return 1;
+    }
+
+    if (list->collection.store_pointer) {
+        // For pointer collections, always use climpl
+        void **target = list->climpl->at(list, index);
+        *target = (void *)elem;
+    } else {
+        void *target = list->cl->at(list, index);
+        memcpy(target, elem, list->collection.elem_size);
+    }
+
+    return 0;
+}

mercurial