mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-05 10:14:05 +00:00
mem: Actually resize when resizing for Stack_Allocator
Changed the check from `bytes` to `err` for safety's sake, too. This will prevent the potential bug of allocating non-zero memory, then doing a zeroed resize, which will result in having garbage data in the initial half.
This commit is contained in:
@@ -1052,8 +1052,8 @@ stack_resize_bytes :: proc(
|
||||
alignment := DEFAULT_ALIGNMENT,
|
||||
loc := #caller_location,
|
||||
) -> ([]byte, Allocator_Error) {
|
||||
bytes, err := stack_alloc_bytes_non_zeroed(s, size, alignment, loc)
|
||||
if bytes != nil {
|
||||
bytes, err := stack_resize_bytes_non_zeroed(s, old_data, size, alignment, loc)
|
||||
if err == nil {
|
||||
if old_data == nil {
|
||||
zero_slice(bytes)
|
||||
} else if size > len(old_data) {
|
||||
|
||||
Reference in New Issue
Block a user