From 3858422f1d9c607736b2b911a3a27678d77afed5 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 9 Nov 2022 20:59:49 +0000 Subject: [PATCH] Use `mem_resize` where possible --- core/runtime/core_builtin.odin | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/core/runtime/core_builtin.odin b/core/runtime/core_builtin.odin index b62f66864..c04d79455 100644 --- a/core/runtime/core_builtin.odin +++ b/core/runtime/core_builtin.odin @@ -541,10 +541,7 @@ reserve_dynamic_array :: proc(array: ^$T/[dynamic]$E, capacity: int, loc := #cal new_size := capacity * size_of(E) allocator := a.allocator - new_data, err := allocator.procedure( - allocator.data, .Resize, new_size, align_of(E), - a.data, old_size, loc, - ) + new_data, err := mem_resize(a.data, old_size, new_size, align_of(E), allocator, loc) if new_data == nil || err != nil { return false } @@ -575,10 +572,7 @@ resize_dynamic_array :: proc(array: ^$T/[dynamic]$E, length: int, loc := #caller new_size := length * size_of(E) allocator := a.allocator - new_data, err := allocator.procedure( - allocator.data, .Resize, new_size, align_of(E), - a.data, old_size, loc, - ) + new_data, err := mem_resize(a.data, old_size, new_size, align_of(E), allocator, loc) if new_data == nil || err != nil { return false } @@ -618,15 +612,7 @@ shrink_dynamic_array :: proc(array: ^$T/[dynamic]$E, new_cap := -1, loc := #call old_size := a.cap * size_of(E) new_size := new_cap * size_of(E) - new_data, err := a.allocator.procedure( - a.allocator.data, - .Resize, - new_size, - align_of(E), - a.data, - old_size, - loc, - ) + new_data, err := mem_resize(a.data, old_size, new_size, align_of(E), allocator, loc) if err != nil { return }