Thu, 03 Oct 2019 11:15:48 +0200
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 |
1.1 --- a/src/array.c Thu Oct 03 10:55:39 2019 +0200 1.2 +++ b/src/array.c Thu Oct 03 11:15:48 2019 +0200 1.3 @@ -66,6 +66,7 @@ 1.4 if (ucx_array_reserve(array, required_capacity)) { 1.5 return 1; 1.6 } 1.7 + return 0; 1.8 } 1.9 1.10 int ucx_array_util_set_a(UcxAllocator* alloc, void** array, size_t* capacity,
2.1 --- a/src/ucx/array.h Thu Oct 03 10:55:39 2019 +0200 2.2 +++ b/src/ucx/array.h Thu Oct 03 11:15:48 2019 +0200 2.3 @@ -188,6 +188,8 @@ 2.4 * If the destination capacity is insufficient, an automatic reallocation is 2.5 * attempted. 2.6 * 2.7 + * Note: if the destination array is uninitialized, the behavior is undefined. 2.8 + * 2.9 * @param dest the array to copy to 2.10 * @param src the array to copy from 2.11 * @return zero on success, non-zero on reallocation failure.
3.1 --- a/test/array_tests.c Thu Oct 03 10:55:39 2019 +0200 3.2 +++ b/test/array_tests.c Thu Oct 03 11:15:48 2019 +0200 3.3 @@ -467,6 +467,7 @@ 3.4 UcxArray array; 3.5 UcxArray copy; 3.6 ucx_array_init(&array, 16, sizeof(int)); 3.7 + ucx_array_init(©, 4, 2*sizeof(double)); 3.8 int *elems; 3.9 3.10 array.size = 5;