mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-22 05:34:59 -07:00
Revert default_resize_bytes_align logic to previous behaviour
This commit is contained in:
+7
-8
@@ -243,11 +243,13 @@ default_resize_bytes_align :: proc(old_data: []byte, new_size, alignment: int, a
|
||||
return alloc_bytes(new_size, alignment, allocator, loc)
|
||||
}
|
||||
|
||||
if new_size == old_size {
|
||||
return old_data, nil
|
||||
}
|
||||
if new_size == 0 {
|
||||
return nil, free_bytes(old_data, allocator, loc)
|
||||
err := free_bytes(old_data, allocator, loc)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if new_size == old_size {
|
||||
return old_data, .None
|
||||
}
|
||||
|
||||
new_memory, err := alloc_bytes(new_size, alignment, allocator, loc)
|
||||
@@ -256,9 +258,6 @@ default_resize_bytes_align :: proc(old_data: []byte, new_size, alignment: int, a
|
||||
}
|
||||
|
||||
runtime.copy(new_memory, old_data)
|
||||
err1 := free_bytes(old_data, allocator, loc)
|
||||
if err == nil {
|
||||
err = err1
|
||||
}
|
||||
free_bytes(old_data, allocator, loc)
|
||||
return new_memory, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user