src/ucx/array.c

branch
webdav
changeset 260
4779a6fb4fbe
parent 254
4784c14aa639
--- a/src/ucx/array.c	Tue Aug 25 12:07:56 2020 +0200
+++ b/src/ucx/array.c	Sat Oct 24 17:34:32 2020 +0200
@@ -70,7 +70,7 @@
 }
 
 int ucx_array_util_set_a(UcxAllocator* alloc, void** array, size_t* capacity,
-    size_t elmsize, size_t index, ...) {
+    size_t elmsize, size_t index, void* data) {
     
     if(!alloc || !capacity || !array) {
         errno = EINVAL;
@@ -104,16 +104,18 @@
     
     char* dest = *array;
     dest += elmsize*index;
-
-    va_list ap;
-    va_start(ap, index);
-    int elem = va_arg(ap, int);    
-    memcpy(dest, &elem, elmsize);
-    va_end(ap);
+    memcpy(dest, data, elmsize);
     
     return 0;
 }
 
+int ucx_array_util_setptr_a(UcxAllocator* alloc, void** array, size_t* capacity,
+    size_t index, void* data) {
+    
+    return ucx_array_util_set_a(alloc, array, capacity, sizeof(void*),
+            index, &data);
+}
+
 UcxArray* ucx_array_new(size_t capacity, size_t elemsize) {
     return ucx_array_new_a(capacity, elemsize, ucx_default_allocator());
 }
@@ -254,33 +256,6 @@
     return 0;
 }
 
-int ucx_array_appendv(UcxArray *array, ...) {
-    va_list ap;
-    va_start(ap, array);
-    int elem = va_arg(ap, int);
-    int ret = ucx_array_append_from(array, &elem, 1);
-    va_end(ap);
-    return ret;
-}
-
-int ucx_array_prependv(UcxArray *array, ...) {
-    va_list ap;
-    va_start(ap, array);
-    int elem = va_arg(ap, int);
-    int ret = ucx_array_prepend_from(array, &elem, 1);
-    va_end(ap);
-    return ret;
-}
-
-int ucx_array_setv(UcxArray *array, size_t index, ...) {
-    va_list ap;
-    va_start(ap, index);
-    int elem = va_arg(ap, int);
-    int ret = ucx_array_set_from(array, index, &elem, 1);
-    va_end(ap);
-    return ret;
-}
-
 int ucx_array_concat(UcxArray *array1, const UcxArray *array2) {
     
     if (array1->elemsize != array2->elemsize)
@@ -404,7 +379,7 @@
 };
 
 static int cmp_func_swap_args(void *data, const void *x, const void *y) {
-    cmpfnc_swapargs_info* info = data;
+    struct cmpfnc_swapargs_info* info = data;
     return info->func(x, y, info->data);
 }
 
@@ -486,3 +461,7 @@
         }
     }
 }
+
+int ucx_array_grow(UcxArray* array, size_t count) {
+    return ucx_array_reserve(array, array->size+count);
+}

mercurial