From c551dfe65ab053b33cffef9a5240e45fb59850c5 Mon Sep 17 00:00:00 2001 From: Alexandros Naskos Date: Fri, 14 Aug 2020 13:53:13 +0300 Subject: [PATCH] Fixed debug allocator to comply with the new API --- src/debug_allocator.zig | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/debug_allocator.zig b/src/debug_allocator.zig index 9a63b87..1c04988 100644 --- a/src/debug_allocator.zig +++ b/src/debug_allocator.zig @@ -104,10 +104,10 @@ pub fn deinit(self: *DebugAllocator) void { self.allocation_strack_addresses.deinit(); } -fn alloc(allocator: *std.mem.Allocator, len: usize, ptr_align: u29, len_align: u29) error{OutOfMemory}![]u8 { +fn alloc(allocator: *std.mem.Allocator, len: usize, ptr_align: u29, len_align: u29, ret_addr: usize) std.mem.Allocator.Error![]u8 { const self = @fieldParentPtr(DebugAllocator, "allocator", allocator); - const ptr = try self.base_allocator.callAllocFn(len, ptr_align, len_align); + const ptr = try self.base_allocator.allocFn(self.base_allocator, len, ptr_align, len_align, ret_addr); self.info.allocation_stats.addSample(ptr.len); var stack_addresses = std.mem.zeroes([stack_addresses_size + 2]usize); @@ -131,7 +131,8 @@ fn alloc(allocator: *std.mem.Allocator, len: usize, ptr_align: u29, len_align: u return ptr; } -fn resize(allocator: *std.mem.Allocator, old_mem: []u8, new_size: usize, len_align: u29) error{OutOfMemory}!usize { +// TODO: Check if this complies with the new allocator interface. +fn resize(allocator: *std.mem.Allocator, old_mem: []u8, buf_align: u29, new_size: usize, len_align: u29, ret_addr: usize) std.mem.Allocator.Error!usize { const self = @fieldParentPtr(DebugAllocator, "allocator", allocator); if (old_mem.len == 0) { @@ -166,7 +167,7 @@ fn resize(allocator: *std.mem.Allocator, old_mem: []u8, new_size: usize, len_ali self.info.peak_allocated = curr_allocs; } - return self.base_allocator.callResizeFn(old_mem, new_size, len_align) catch |e| { + return self.base_allocator.resizeFn(self.base_allocator, old_mem, buf_align, new_size, len_align, ret_addr) catch |e| { return e; }; }