From bd659e64fc30675236f8f659ed685cf49248a6ce Mon Sep 17 00:00:00 2001 From: Abdelrahman Said Date: Thu, 22 Jan 2026 06:09:43 +0000 Subject: [PATCH] Ensure array count is set correctly when allocating --- src/base/array/array.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/base/array/array.c b/src/base/array/array.c index 93aae06..b720432 100644 --- a/src/base/array/array.c +++ b/src/base/array/array.c @@ -125,6 +125,10 @@ GenericArray _array_append_alloc(const Allocator *allocator, GenericArray array, _array_append_capped(output, value, item_size); + if ((flags & ARRAY_INIT_FILLED) == ARRAY_INIT_FILLED) { + _array_set_count(output, _array_capacity(output)); + } + RETURN_ARRAY_APPEND_ALLOC: return output; } @@ -153,6 +157,10 @@ GenericArray _array_extend_alloc(const Allocator *allocator, GenericArray dst, c _array_extend_capped(output, src, item_size); + if ((flags & ARRAY_INIT_FILLED) == ARRAY_INIT_FILLED) { + _array_set_count(output, _array_capacity(output)); + } + RETURN_ARRAY_EXTEND_ALLOC: return output; } @@ -179,6 +187,10 @@ GenericArray _array_copy_alloc(const Allocator *allocator, GenericArray dst, con _array_copy_capped(output, src, item_size); + if ((flags & ARRAY_INIT_FILLED) == ARRAY_INIT_FILLED) { + _array_set_count(output, _array_capacity(output)); + } + RETURN_ARRAY_COPY_ALLOC: return output; }