fixes two bugs: clone to uninitialized array and missing return in ucx_array_ensurecap() feature/array

Thu, 03 Oct 2019 11:15:48 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 03 Oct 2019 11:15:48 +0200
branch
feature/array
changeset 357
0f5732f0dc00
parent 356
77efe51c6c9a
child 358
885f31c6098b

fixes two bugs: clone to uninitialized array and missing return in ucx_array_ensurecap()

src/array.c file | annotate | diff | comparison | revisions
src/ucx/array.h file | annotate | diff | comparison | revisions
test/array_tests.c file | annotate | diff | comparison | revisions
--- a/src/array.c	Thu Oct 03 10:55:39 2019 +0200
+++ b/src/array.c	Thu Oct 03 11:15:48 2019 +0200
@@ -66,6 +66,7 @@
     if (ucx_array_reserve(array, required_capacity)) {
         return 1;
     }
+    return 0;
 }
 
 int ucx_array_util_set_a(UcxAllocator* alloc, void** array, size_t* capacity,
--- a/src/ucx/array.h	Thu Oct 03 10:55:39 2019 +0200
+++ b/src/ucx/array.h	Thu Oct 03 11:15:48 2019 +0200
@@ -188,6 +188,8 @@
  * If the destination capacity is insufficient, an automatic reallocation is
  * attempted.
  * 
+ * Note: if the destination array is uninitialized, the behavior is undefined.
+ * 
  * @param dest the array to copy to
  * @param src the array to copy from
  * @return zero on success, non-zero on reallocation failure.
--- a/test/array_tests.c	Thu Oct 03 10:55:39 2019 +0200
+++ b/test/array_tests.c	Thu Oct 03 11:15:48 2019 +0200
@@ -467,6 +467,7 @@
     UcxArray array;
     UcxArray copy;
     ucx_array_init(&array, 16, sizeof(int));
+    ucx_array_init(&copy, 4, 2*sizeof(double));
     int *elems;
     
     array.size = 5;

mercurial