Sun, 20 Nov 2022 17:48:42 +0100
fix cx_array_copy() unintentionally shrinking the array
src/array_list.c | file | annotate | diff | comparison | revisions |
1.1 --- a/src/array_list.c Sun Nov 20 17:47:26 2022 +0100 1.2 +++ b/src/array_list.c Sun Nov 20 17:48:42 2022 +0100 1.3 @@ -52,7 +52,8 @@ 1.4 size_t cap = capacity == NULL ? *size : *capacity; 1.5 1.6 /* check if resize is required */ 1.7 - size_t newsize = index + elem_count; 1.8 + size_t minsize = index + elem_count; 1.9 + size_t newsize = *size < minsize ? minsize : *size; 1.10 bool needrealloc = newsize > cap; 1.11 1.12 /* reallocate if possible */