From 18a2980d26602028977da151a0af1a43097b7830 Mon Sep 17 00:00:00 2001 From: Damian Tarnawski Date: Sat, 23 Aug 2025 14:28:25 +0200 Subject: [PATCH] Zero existing memory when using resize_soa (fixes #5614) --- base/runtime/core_builtin_soa.odin | 24 ++++++++++++++++ tests/core/runtime/test_core_runtime.odin | 34 +++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/base/runtime/core_builtin_soa.odin b/base/runtime/core_builtin_soa.odin index ff27a4559..3cbf82bdc 100644 --- a/base/runtime/core_builtin_soa.odin +++ b/base/runtime/core_builtin_soa.odin @@ -178,9 +178,33 @@ resize_soa :: proc(array: ^$T/#soa[dynamic]$E, #any_int length: int, loc := #cal if array == nil { return nil } + reserve_soa(array, length, loc) or_return footer := raw_soa_footer(array) + old_len := footer.len footer.len = length + + if size_of(E) > 0 && length > old_len { + ti := type_info_of(typeid_of(T)) + ti = type_info_base(ti) + si := &ti.variant.(Type_Info_Struct) + + field_count := len(E) when intrinsics.type_is_array(E) else intrinsics.type_struct_field_count(E) + + data := (^rawptr)(array)^ + + soa_offset := 0 + for i in 0..