mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Fixed zeroing in resize_dynamic_array.
When a dynamic array has unused capacity and is resized to a size greater than its capacity, the unused part of its capacity wasn't being zeroed.
This commit is contained in:
@@ -826,10 +826,12 @@ _resize_dynamic_array :: #force_inline proc(a: ^Raw_Dynamic_Array, size_of_elem,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if should_zero && a.len < length {
|
||||||
|
num_reused := min(a.cap, length) - a.len
|
||||||
|
intrinsics.mem_zero(([^]byte)(a.data)[a.len*size_of_elem:], num_reused*size_of_elem)
|
||||||
|
}
|
||||||
|
|
||||||
if length <= a.cap {
|
if length <= a.cap {
|
||||||
if should_zero && a.len < length {
|
|
||||||
intrinsics.mem_zero(([^]byte)(a.data)[a.len*size_of_elem:], (length-a.len)*size_of_elem)
|
|
||||||
}
|
|
||||||
a.len = max(length, 0)
|
a.len = max(length, 0)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user