mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Use mem_resize where possible
This commit is contained in:
@@ -541,10 +541,7 @@ reserve_dynamic_array :: proc(array: ^$T/[dynamic]$E, capacity: int, loc := #cal
|
|||||||
new_size := capacity * size_of(E)
|
new_size := capacity * size_of(E)
|
||||||
allocator := a.allocator
|
allocator := a.allocator
|
||||||
|
|
||||||
new_data, err := allocator.procedure(
|
new_data, err := mem_resize(a.data, old_size, new_size, align_of(E), allocator, loc)
|
||||||
allocator.data, .Resize, new_size, align_of(E),
|
|
||||||
a.data, old_size, loc,
|
|
||||||
)
|
|
||||||
if new_data == nil || err != nil {
|
if new_data == nil || err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -575,10 +572,7 @@ resize_dynamic_array :: proc(array: ^$T/[dynamic]$E, length: int, loc := #caller
|
|||||||
new_size := length * size_of(E)
|
new_size := length * size_of(E)
|
||||||
allocator := a.allocator
|
allocator := a.allocator
|
||||||
|
|
||||||
new_data, err := allocator.procedure(
|
new_data, err := mem_resize(a.data, old_size, new_size, align_of(E), allocator, loc)
|
||||||
allocator.data, .Resize, new_size, align_of(E),
|
|
||||||
a.data, old_size, loc,
|
|
||||||
)
|
|
||||||
if new_data == nil || err != nil {
|
if new_data == nil || err != nil {
|
||||||
return false
|
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)
|
old_size := a.cap * size_of(E)
|
||||||
new_size := new_cap * size_of(E)
|
new_size := new_cap * size_of(E)
|
||||||
|
|
||||||
new_data, err := a.allocator.procedure(
|
new_data, err := mem_resize(a.data, old_size, new_size, align_of(E), allocator, loc)
|
||||||
a.allocator.data,
|
|
||||||
.Resize,
|
|
||||||
new_size,
|
|
||||||
align_of(E),
|
|
||||||
a.data,
|
|
||||||
old_size,
|
|
||||||
loc,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user