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 |
--- a/src/array_list.c Sun Nov 20 17:47:26 2022 +0100 +++ b/src/array_list.c Sun Nov 20 17:48:42 2022 +0100 @@ -52,7 +52,8 @@ size_t cap = capacity == NULL ? *size : *capacity; /* check if resize is required */ - size_t newsize = index + elem_count; + size_t minsize = index + elem_count; + size_t newsize = *size < minsize ? minsize : *size; bool needrealloc = newsize > cap; /* reallocate if possible */