mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 14:18:47 +00:00
mem: Don't change Scratch_Allocator's backup allocator
The backup allocator is set at `init` and must stay the same for the lifetime of the Scratch allocator, as this allocator is used to free all `leaked_allocations`. Changing it could lead to a situation where the wrong allocator is used to free a leaked allocation.
This commit is contained in:
@@ -541,10 +541,6 @@ scratch_alloc_bytes_non_zeroed :: proc(
|
|||||||
} else {
|
} else {
|
||||||
// NOTE: No need to use `aligned_size` here, as the backup allocator will handle alignment for us.
|
// NOTE: No need to use `aligned_size` here, as the backup allocator will handle alignment for us.
|
||||||
a := s.backup_allocator
|
a := s.backup_allocator
|
||||||
if a.procedure == nil {
|
|
||||||
a = context.allocator
|
|
||||||
s.backup_allocator = a
|
|
||||||
}
|
|
||||||
ptr, err := alloc_bytes_non_zeroed(size, alignment, a, loc)
|
ptr, err := alloc_bytes_non_zeroed(size, alignment, a, loc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ptr, err
|
return ptr, err
|
||||||
|
|||||||
Reference in New Issue
Block a user