diff options
| author | Lee Cannon <leecannon@leecannon.xyz> | 2021-12-02 15:39:25 +0000 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-12-02 11:56:32 -0800 |
| commit | fb9fcf5632468b2aa8af73f4e3269a01535076f5 (patch) | |
| tree | 7f744cf7155647485155db00539dbe056c6205f6 /lib/std | |
| parent | 14b532ec8596d7f84b76127f1b858271f010126f (diff) | |
| download | zig-fb9fcf5632468b2aa8af73f4e3269a01535076f5.tar.gz zig-fb9fcf5632468b2aa8af73f4e3269a01535076f5.zip | |
allocator: Move vtable into gen struct
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/mem/Allocator.zig | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/std/mem/Allocator.zig b/lib/std/mem/Allocator.zig index 29fbf7c2c1..7960581b0f 100644 --- a/lib/std/mem/Allocator.zig +++ b/lib/std/mem/Allocator.zig @@ -67,30 +67,30 @@ pub fn init( const alignment = ptr_info.Pointer.alignment; const gen = struct { - fn alloc(ptr: *c_void, len: usize, ptr_align: u29, len_align: u29, ret_addr: usize) Error![]u8 { + fn allocImpl(ptr: *c_void, len: usize, ptr_align: u29, len_align: u29, ret_addr: usize) Error![]u8 { const self = @ptrCast(Ptr, @alignCast(alignment, ptr)); return @call(.{ .modifier = .always_inline }, allocFn, .{ self, len, ptr_align, len_align, ret_addr }); } - fn resize(ptr: *c_void, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, ret_addr: usize) ?usize { + fn resizeImpl(ptr: *c_void, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, ret_addr: usize) ?usize { assert(new_len != 0); const self = @ptrCast(Ptr, @alignCast(alignment, ptr)); return @call(.{ .modifier = .always_inline }, resizeFn, .{ self, buf, buf_align, new_len, len_align, ret_addr }); } - fn free(ptr: *c_void, buf: []u8, buf_align: u29, ret_addr: usize) void { + fn freeImpl(ptr: *c_void, buf: []u8, buf_align: u29, ret_addr: usize) void { const self = @ptrCast(Ptr, @alignCast(alignment, ptr)); @call(.{ .modifier = .always_inline }, freeFn, .{ self, buf, buf_align, ret_addr }); } - }; - const vtable = VTable{ - .alloc = gen.alloc, - .resize = gen.resize, - .free = gen.free, + const vtable = VTable{ + .alloc = allocImpl, + .resize = resizeImpl, + .free = freeImpl, + }; }; return .{ .ptr = pointer, - .vtable = &vtable, + .vtable = &gen.vtable, }; } |
