diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2021-03-18 10:44:09 +0100 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2021-03-18 10:44:09 +0100 |
| commit | 6ff8c1b780759d02156bf4c69c3c443ece12c160 (patch) | |
| tree | 1ce5fc6f27310952b814670cf8bffc8ddccd532b /src/common/allocator.odin | |
| parent | 2313142359f69769b838b835f15c726d1ce2ebb4 (diff) | |
ran odinfmt
Diffstat (limited to 'src/common/allocator.odin')
| -rw-r--r-- | src/common/allocator.odin | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/common/allocator.odin b/src/common/allocator.odin index a7bfae7..4f72f81 100644 --- a/src/common/allocator.odin +++ b/src/common/allocator.odin @@ -30,15 +30,15 @@ scratch_allocator_destroy :: proc (s: ^Scratch_Allocator) { s^ = {}; } -scratch_allocator_proc :: proc (allocator_data: rawptr, mode: mem.Allocator_Mode, -size, alignment: int, +scratch_allocator_proc :: proc (allocator_data: rawptr, mode: mem.Allocator_Mode, +size, alignment: int, old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> rawptr { s := (^Scratch_Allocator)(allocator_data); if s.data == nil { DEFAULT_BACKING_SIZE :: 1 << 22; - if !(context.allocator.procedure != scratch_allocator_proc && + if !(context.allocator.procedure != scratch_allocator_proc && context.allocator.data != allocator_data) { panic("cyclic initialization of the scratch allocator with itself"); } @@ -54,7 +54,7 @@ old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> r switch { case s.curr_offset + size <= len(s.data): start := uintptr(raw_data(s.data)); - ptr := start + uintptr(s.curr_offset); + ptr := start + uintptr(s.curr_offset); ptr = mem.align_forward_uintptr(ptr, uintptr(alignment)); mem.zero(rawptr(ptr), size); @@ -79,7 +79,7 @@ old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> r case .Free: case .Free_All: - s.curr_offset = 0; + s.curr_offset = 0; s.prev_allocation = nil; for ptr in s.leaked_allocations { free(ptr, s.backup_allocator); @@ -87,8 +87,8 @@ old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> r clear(&s.leaked_allocations); case .Resize: - begin := uintptr(raw_data(s.data)); - end := begin + uintptr(len(s.data)); + 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; |