aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-01-29 16:21:26 +0000
committergingerBill <bill@gingerbill.org>2024-01-29 16:21:26 +0000
commit9c9ae5987a561eca67f1fb9599e6a2b1dc374fd5 (patch)
tree56648ac4b100a0f370ed807bd356e2d773265a48
parentf588593ff15fa13e89bd869a52b2ff9bf9d91341 (diff)
Fix #3150
-rw-r--r--base/runtime/core_builtin.odin1
-rw-r--r--base/runtime/core_builtin_soa.odin1
2 files changed, 2 insertions, 0 deletions
diff --git a/base/runtime/core_builtin.odin b/base/runtime/core_builtin.odin
index 3692751bb..f576adcc2 100644
--- a/base/runtime/core_builtin.odin
+++ b/base/runtime/core_builtin.odin
@@ -312,6 +312,7 @@ make_dynamic_array_len :: proc($T: typeid/[dynamic]$E, #any_int len: int, alloca
@(builtin, require_results)
make_dynamic_array_len_cap :: proc($T: typeid/[dynamic]$E, #any_int len: int, #any_int cap: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error {
make_dynamic_array_error_loc(loc, len, cap)
+ array.allocator = allocator // initialize allocator before just in case it fails to allocate any memory
data := mem_alloc_bytes(size_of(E)*cap, align_of(E), allocator, loc) or_return
s := Raw_Dynamic_Array{raw_data(data), len, cap, allocator}
if data == nil && size_of(E) != 0 {
diff --git a/base/runtime/core_builtin_soa.odin b/base/runtime/core_builtin_soa.odin
index 94f5be1d4..1b2e5d316 100644
--- a/base/runtime/core_builtin_soa.odin
+++ b/base/runtime/core_builtin_soa.odin
@@ -86,6 +86,7 @@ make_soa_aligned :: proc($T: typeid/#soa[]$E, length: int, alignment: int, alloc
return
}
+ array.allocator = allocator
footer := raw_soa_footer(&array)
if size_of(E) == 0 {
footer.len = length