From 05706864b7cdbd8fabf09dd8cb4d55e1e9174acf Mon Sep 17 00:00:00 2001 From: Damian Tarnawski Date: Sat, 23 Aug 2025 12:55:07 +0200 Subject: Support using allocator resize in `_reserve_soa` (fixes #5615) --- base/runtime/core_builtin_soa.odin | 56 ++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 5 deletions(-) (limited to 'base') diff --git a/base/runtime/core_builtin_soa.odin b/base/runtime/core_builtin_soa.odin index ff27a4559..5baeb9e24 100644 --- a/base/runtime/core_builtin_soa.odin +++ b/base/runtime/core_builtin_soa.odin @@ -249,17 +249,63 @@ _reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, capacity: int, zero_memory: boo old_data := (^rawptr)(array)^ - new_bytes := array.allocator.procedure( + new_bytes, resize_err := array.allocator.procedure( + array.allocator.data, .Resize if zero_memory else .Resize_Non_Zeroed, new_size, max_align, + old_data, old_size, loc, + ) + new_data := raw_data(new_bytes) + + old_offset := 0 + new_offset := 0 + + if resize_err == .None { + + footer.cap = capacity + + // Adjust layout + // before: |x x y y z z| + // now: |x x y y z z _ _ _| + // after: |x x _ y y _ z z _| + + for i in 0..