From fcbb7426faac5e693ef195defe2d8d2a2eddadb1 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 31 May 2018 10:56:59 -0400 Subject: use * for pointer type instead of & See #770 To help automatically translate code, see the zig-fmt-pointer-reform-2 branch. This will convert all & into *. Due to the syntax ambiguity (which is why we are making this change), even address-of & will turn into *, so you'll have to manually fix thes instances. You will be guaranteed to get compile errors for them - expected 'type', found 'foo' --- std/debug/failing_allocator.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'std/debug/failing_allocator.zig') diff --git a/std/debug/failing_allocator.zig b/std/debug/failing_allocator.zig index 6b5edff5bf..e16dd21db4 100644 --- a/std/debug/failing_allocator.zig +++ b/std/debug/failing_allocator.zig @@ -7,12 +7,12 @@ pub const FailingAllocator = struct { allocator: mem.Allocator, index: usize, fail_index: usize, - internal_allocator: &mem.Allocator, + internal_allocator: *mem.Allocator, allocated_bytes: usize, freed_bytes: usize, deallocations: usize, - pub fn init(allocator: &mem.Allocator, fail_index: usize) FailingAllocator { + pub fn init(allocator: *mem.Allocator, fail_index: usize) FailingAllocator { return FailingAllocator{ .internal_allocator = allocator, .fail_index = fail_index, @@ -28,7 +28,7 @@ pub const FailingAllocator = struct { }; } - fn alloc(allocator: &mem.Allocator, n: usize, alignment: u29) ![]u8 { + fn alloc(allocator: *mem.Allocator, n: usize, alignment: u29) ![]u8 { const self = @fieldParentPtr(FailingAllocator, "allocator", allocator); if (self.index == self.fail_index) { return error.OutOfMemory; @@ -39,7 +39,7 @@ pub const FailingAllocator = struct { return result; } - fn realloc(allocator: &mem.Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![]u8 { + fn realloc(allocator: *mem.Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![]u8 { const self = @fieldParentPtr(FailingAllocator, "allocator", allocator); if (new_size <= old_mem.len) { self.freed_bytes += old_mem.len - new_size; @@ -55,7 +55,7 @@ pub const FailingAllocator = struct { return result; } - fn free(allocator: &mem.Allocator, bytes: []u8) void { + fn free(allocator: *mem.Allocator, bytes: []u8) void { const self = @fieldParentPtr(FailingAllocator, "allocator", allocator); self.freed_bytes += bytes.len; self.deallocations += 1; -- cgit v1.2.3