diff options
| author | gingerBill <bill@gingerbill.org> | 2020-10-13 14:40:13 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-10-13 14:40:13 +0100 |
| commit | fa33476438521fcc6ec886e43f64efb82e0c16dd (patch) | |
| tree | 27ad65889c3b1b29f0ffbca1980b92a692a11519 /core/runtime/default_allocators.odin | |
| parent | 1b4bccbc9401b3b00735038906d7ad6c2e309e95 (diff) | |
Improve default temp allocator; Fix filepath.abs behaviour on Windows
Diffstat (limited to 'core/runtime/default_allocators.odin')
| -rw-r--r-- | core/runtime/default_allocators.odin | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/core/runtime/default_allocators.odin b/core/runtime/default_allocators.odin index d4086ffe8..b9d18524f 100644 --- a/core/runtime/default_allocators.odin +++ b/core/runtime/default_allocators.odin @@ -123,6 +123,10 @@ default_temp_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode return ptr; case .Free: + if old_memory == nil { + return nil; + } + start := uintptr(raw_data(s.data)); end := start + uintptr(len(s.data)); old_ptr := uintptr(old_memory); @@ -161,9 +165,11 @@ default_temp_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode begin := uintptr(raw_data(s.data)); end := begin + uintptr(len(s.data)); old_ptr := uintptr(old_memory); - if begin <= old_ptr && old_ptr < end && old_ptr+uintptr(size) < end { - s.curr_offset = int(old_ptr-begin)+size; - return old_memory; + if old_memory == s.prev_allocation && old_ptr & uintptr(alignment)-1 == 0 { + if old_ptr+uintptr(size) < end { + s.curr_offset = int(old_ptr-begin)+size; + return old_memory; + } } ptr := default_temp_allocator_proc(allocator_data, .Alloc, size, alignment, old_memory, old_size, flags, loc); mem_copy(ptr, old_memory, old_size); |