| author | |
| committer | |
| log | 1093b09a989edb8553e79b061bb15c5745f5d193 |
| tree | 4e87b6b48410b901239a102f5fbdf859816511d1 |
| parent | 75548b50ff23a3de48d166170425001c073d27c1 |
| signature |
77 files changed, 202 insertions(+), 207 deletions(-)
ci/srht/update-download-page.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ pub fn main() !void { |
| 6 | 6 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 7 | 7 | defer arena.deinit(); |
| 8 | 8 | |
| 9 | const allocator = arena.getAllocator(); | |
| 9 | const allocator = arena.allocator(); | |
| 10 | 10 | |
| 11 | 11 | const out_dir = "out"; |
| 12 | 12 | try std.fs.cwd().makePath(out_dir); |
doc/docgen.zig+1-1| ... | ... | @@ -21,7 +21,7 @@ pub fn main() !void { |
| 21 | 21 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 22 | 22 | defer arena.deinit(); |
| 23 | 23 | |
| 24 | const allocator = arena.getAllocator(); | |
| 24 | const allocator = arena.allocator(); | |
| 25 | 25 | |
| 26 | 26 | var args_it = process.args(); |
| 27 | 27 |
doc/langref.html.in+4-4| ... | ... | @@ -10061,7 +10061,7 @@ const expect = std.testing.expect; |
| 10061 | 10061 | |
| 10062 | 10062 | test "using an allocator" { |
| 10063 | 10063 | var buffer: [100]u8 = undefined; |
| 10064 | const allocator = std.heap.FixedBufferAllocator.init(&buffer).getAllocator(); | |
| 10064 | const allocator = std.heap.FixedBufferAllocator.init(&buffer).allocator(); | |
| 10065 | 10065 | const result = try concat(allocator, "foo", "bar"); |
| 10066 | 10066 | try expect(std.mem.eql(u8, "foobar", result)); |
| 10067 | 10067 | } |
| ... | ... | @@ -10114,7 +10114,7 @@ pub fn main() !void { |
| 10114 | 10114 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 10115 | 10115 | defer arena.deinit(); |
| 10116 | 10116 | |
| 10117 | const allocator = arena.getAllocator(); | |
| 10117 | const allocator = arena.allocator(); | |
| 10118 | 10118 | |
| 10119 | 10119 | const ptr = try allocator.create(i32); |
| 10120 | 10120 | std.debug.print("ptr={*}\n", .{ptr}); |
| ... | ... | @@ -10820,7 +10820,7 @@ const std = @import("std"); |
| 10820 | 10820 | |
| 10821 | 10821 | pub fn main() !void { |
| 10822 | 10822 | var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){}; |
| 10823 | const gpa = general_purpose_allocator.getAllocator(); | |
| 10823 | const gpa = general_purpose_allocator.allocator(); | |
| 10824 | 10824 | const args = try std.process.argsAlloc(gpa); |
| 10825 | 10825 | defer std.process.argsFree(gpa, args); |
| 10826 | 10826 | |
| ... | ... | @@ -10842,7 +10842,7 @@ const PreopenList = std.fs.wasi.PreopenList; |
| 10842 | 10842 | |
| 10843 | 10843 | pub fn main() !void { |
| 10844 | 10844 | var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){}; |
| 10845 | const gpa = general_purpose_allocator.getAllocator(); | |
| 10845 | const gpa = general_purpose_allocator.allocator(); | |
| 10846 | 10846 | |
| 10847 | 10847 | var preopens = PreopenList.init(gpa); |
| 10848 | 10848 | defer preopens.deinit(); |
lib/std/Thread.zig+1-1| ... | ... | @@ -460,7 +460,7 @@ const WindowsThreadImpl = struct { |
| 460 | 460 | errdefer assert(windows.kernel32.HeapFree(heap_handle, 0, alloc_ptr) != 0); |
| 461 | 461 | |
| 462 | 462 | const instance_bytes = @ptrCast([*]u8, alloc_ptr)[0..alloc_bytes]; |
| 463 | const instance = std.heap.FixedBufferAllocator.init(instance_bytes).getAllocator().create(Instance) catch unreachable; | |
| 463 | const instance = std.heap.FixedBufferAllocator.init(instance_bytes).allocator().create(Instance) catch unreachable; | |
| 464 | 464 | instance.* = .{ |
| 465 | 465 | .fn_args = args, |
| 466 | 466 | .thread = .{ |
lib/std/array_list.zig+3-3| ... | ... | @@ -1119,7 +1119,7 @@ test "std.ArrayList/ArrayListUnmanaged.insertSlice" { |
| 1119 | 1119 | test "std.ArrayList/ArrayListUnmanaged.replaceRange" { |
| 1120 | 1120 | var arena = std.heap.ArenaAllocator.init(testing.allocator); |
| 1121 | 1121 | defer arena.deinit(); |
| 1122 | const a = arena.getAllocator(); | |
| 1122 | const a = arena.allocator(); | |
| 1123 | 1123 | |
| 1124 | 1124 | const init = [_]i32{ 1, 2, 3, 4, 5 }; |
| 1125 | 1125 | const new = [_]i32{ 0, 0, 0 }; |
| ... | ... | @@ -1263,7 +1263,7 @@ test "std.ArrayList/ArrayListUnmanaged.shrink still sets length on error.OutOfMe |
| 1263 | 1263 | // use an arena allocator to make sure realloc returns error.OutOfMemory |
| 1264 | 1264 | var arena = std.heap.ArenaAllocator.init(testing.allocator); |
| 1265 | 1265 | defer arena.deinit(); |
| 1266 | const a = arena.getAllocator(); | |
| 1266 | const a = arena.allocator(); | |
| 1267 | 1267 | |
| 1268 | 1268 | { |
| 1269 | 1269 | var list = ArrayList(i32).init(a); |
| ... | ... | @@ -1361,7 +1361,7 @@ test "ArrayListAligned/ArrayListAlignedUnmanaged accepts unaligned slices" { |
| 1361 | 1361 | |
| 1362 | 1362 | test "std.ArrayList(u0)" { |
| 1363 | 1363 | // An ArrayList on zero-sized types should not need to allocate |
| 1364 | const a = testing.FailingAllocator.init(testing.allocator, 0).getAllocator(); | |
| 1364 | const a = testing.FailingAllocator.init(testing.allocator, 0).allocator(); | |
| 1365 | 1365 | |
| 1366 | 1366 | var list = ArrayList(u0).init(a); |
| 1367 | 1367 | defer list.deinit(); |
lib/std/atomic/queue.zig+1-1| ... | ... | @@ -177,7 +177,7 @@ test "std.atomic.Queue" { |
| 177 | 177 | defer std.heap.page_allocator.free(plenty_of_memory); |
| 178 | 178 | |
| 179 | 179 | var fixed_buffer_allocator = std.heap.FixedBufferAllocator.init(plenty_of_memory); |
| 180 | var a = fixed_buffer_allocator.getThreadSafeAllocator(); | |
| 180 | var a = fixed_buffer_allocator.threadSafeAllocator(); | |
| 181 | 181 | |
| 182 | 182 | var queue = Queue(i32).init(); |
| 183 | 183 | var context = Context{ |
lib/std/atomic/stack.zig+1-1| ... | ... | @@ -89,7 +89,7 @@ test "std.atomic.stack" { |
| 89 | 89 | defer std.heap.page_allocator.free(plenty_of_memory); |
| 90 | 90 | |
| 91 | 91 | var fixed_buffer_allocator = std.heap.FixedBufferAllocator.init(plenty_of_memory); |
| 92 | var a = fixed_buffer_allocator.getThreadSafeAllocator(); | |
| 92 | var a = fixed_buffer_allocator.threadSafeAllocator(); | |
| 93 | 93 | |
| 94 | 94 | var stack = Stack(i32).init(); |
| 95 | 95 | var context = Context{ |
lib/std/build.zig+3-3| ... | ... | @@ -1285,7 +1285,7 @@ test "builder.findProgram compiles" { |
| 1285 | 1285 | defer arena.deinit(); |
| 1286 | 1286 | |
| 1287 | 1287 | const builder = try Builder.create( |
| 1288 | arena.getAllocator(), | |
| 1288 | arena.allocator(), | |
| 1289 | 1289 | "zig", |
| 1290 | 1290 | "zig-cache", |
| 1291 | 1291 | "zig-cache", |
| ... | ... | @@ -3207,7 +3207,7 @@ test "Builder.dupePkg()" { |
| 3207 | 3207 | var arena = std.heap.ArenaAllocator.init(std.testing.allocator); |
| 3208 | 3208 | defer arena.deinit(); |
| 3209 | 3209 | var builder = try Builder.create( |
| 3210 | arena.getAllocator(), | |
| 3210 | arena.allocator(), | |
| 3211 | 3211 | "test", |
| 3212 | 3212 | "test", |
| 3213 | 3213 | "test", |
| ... | ... | @@ -3252,7 +3252,7 @@ test "LibExeObjStep.addPackage" { |
| 3252 | 3252 | defer arena.deinit(); |
| 3253 | 3253 | |
| 3254 | 3254 | var builder = try Builder.create( |
| 3255 | arena.getAllocator(), | |
| 3255 | arena.allocator(), | |
| 3256 | 3256 | "test", |
| 3257 | 3257 | "test", |
| 3258 | 3258 | "test", |
lib/std/build/OptionsStep.zig+1-1| ... | ... | @@ -274,7 +274,7 @@ test "OptionsStep" { |
| 274 | 274 | var arena = std.heap.ArenaAllocator.init(std.testing.allocator); |
| 275 | 275 | defer arena.deinit(); |
| 276 | 276 | var builder = try Builder.create( |
| 277 | arena.getAllocator(), | |
| 277 | arena.allocator(), | |
| 278 | 278 | "test", |
| 279 | 279 | "test", |
| 280 | 280 | "test", |
lib/std/builtin.zig+1-1| ... | ... | @@ -75,7 +75,7 @@ pub const StackTrace = struct { |
| 75 | 75 | }; |
| 76 | 76 | const tty_config = std.debug.detectTTYConfig(); |
| 77 | 77 | try writer.writeAll("\n"); |
| 78 | std.debug.writeStackTrace(self, writer, arena.getAllocator(), debug_info, tty_config) catch |err| { | |
| 78 | std.debug.writeStackTrace(self, writer, arena.allocator(), debug_info, tty_config) catch |err| { | |
| 79 | 79 | try writer.print("Unable to print stack trace: {s}\n", .{@errorName(err)}); |
| 80 | 80 | }; |
| 81 | 81 | try writer.writeAll("\n"); |
lib/std/child_process.zig+2-2| ... | ... | @@ -541,7 +541,7 @@ pub const ChildProcess = struct { |
| 541 | 541 | |
| 542 | 542 | var arena_allocator = std.heap.ArenaAllocator.init(self.allocator); |
| 543 | 543 | defer arena_allocator.deinit(); |
| 544 | const arena = arena_allocator.getAllocator(); | |
| 544 | const arena = arena_allocator.allocator(); | |
| 545 | 545 | |
| 546 | 546 | // The POSIX standard does not allow malloc() between fork() and execve(), |
| 547 | 547 | // and `self.allocator` may be a libc allocator. |
| ... | ... | @@ -1149,7 +1149,7 @@ test "createNullDelimitedEnvMap" { |
| 1149 | 1149 | |
| 1150 | 1150 | var arena = std.heap.ArenaAllocator.init(allocator); |
| 1151 | 1151 | defer arena.deinit(); |
| 1152 | const environ = try createNullDelimitedEnvMap(arena.getAllocator(), &envmap); | |
| 1152 | const environ = try createNullDelimitedEnvMap(arena.allocator(), &envmap); | |
| 1153 | 1153 | |
| 1154 | 1154 | try testing.expectEqual(@as(usize, 5), environ.len); |
| 1155 | 1155 |
lib/std/crypto/benchmark.zig+1-1| ... | ... | @@ -363,7 +363,7 @@ pub fn main() !void { |
| 363 | 363 | |
| 364 | 364 | var buffer: [1024]u8 = undefined; |
| 365 | 365 | var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]); |
| 366 | const args = try std.process.argsAlloc(fixed.getAllocator()); | |
| 366 | const args = try std.process.argsAlloc(fixed.allocator()); | |
| 367 | 367 | |
| 368 | 368 | var filter: ?[]u8 = ""; |
| 369 | 369 |
lib/std/debug.zig+1-1| ... | ... | @@ -1566,7 +1566,7 @@ fn getDebugInfoAllocator() mem.Allocator { |
| 1566 | 1566 | if (debug_info_allocator) |a| return a; |
| 1567 | 1567 | |
| 1568 | 1568 | debug_info_arena_allocator = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 1569 | const allocator = debug_info_arena_allocator.getAllocator(); | |
| 1569 | const allocator = debug_info_arena_allocator.allocator(); | |
| 1570 | 1570 | debug_info_allocator = allocator; |
| 1571 | 1571 | return allocator; |
| 1572 | 1572 | } |
lib/std/event/loop.zig+2-2| ... | ... | @@ -173,12 +173,12 @@ pub const Loop = struct { |
| 173 | 173 | // We need at least one of these in case the fs thread wants to use onNextTick |
| 174 | 174 | const extra_thread_count = thread_count - 1; |
| 175 | 175 | const resume_node_count = std.math.max(extra_thread_count, 1); |
| 176 | self.eventfd_resume_nodes = try self.arena.getAllocator().alloc( | |
| 176 | self.eventfd_resume_nodes = try self.arena.allocator().alloc( | |
| 177 | 177 | std.atomic.Stack(ResumeNode.EventFd).Node, |
| 178 | 178 | resume_node_count, |
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | self.extra_threads = try self.arena.getAllocator().alloc(Thread, extra_thread_count); | |
| 181 | self.extra_threads = try self.arena.allocator().alloc(Thread, extra_thread_count); | |
| 182 | 182 | |
| 183 | 183 | try self.initOsData(extra_thread_count); |
| 184 | 184 | errdefer self.deinitOsData(); |
lib/std/fs/test.zig+7-7| ... | ... | @@ -52,7 +52,7 @@ test "accessAbsolute" { |
| 52 | 52 | |
| 53 | 53 | var arena = ArenaAllocator.init(testing.allocator); |
| 54 | 54 | defer arena.deinit(); |
| 55 | const allocator = arena.getAllocator(); | |
| 55 | const allocator = arena.allocator(); | |
| 56 | 56 | |
| 57 | 57 | const base_path = blk: { |
| 58 | 58 | const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] }); |
| ... | ... | @@ -71,7 +71,7 @@ test "openDirAbsolute" { |
| 71 | 71 | try tmp.dir.makeDir("subdir"); |
| 72 | 72 | var arena = ArenaAllocator.init(testing.allocator); |
| 73 | 73 | defer arena.deinit(); |
| 74 | const allocator = arena.getAllocator(); | |
| 74 | const allocator = arena.allocator(); | |
| 75 | 75 | |
| 76 | 76 | const base_path = blk: { |
| 77 | 77 | const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..], "subdir" }); |
| ... | ... | @@ -111,7 +111,7 @@ test "readLinkAbsolute" { |
| 111 | 111 | // Get base abs path |
| 112 | 112 | var arena = ArenaAllocator.init(testing.allocator); |
| 113 | 113 | defer arena.deinit(); |
| 114 | const allocator = arena.getAllocator(); | |
| 114 | const allocator = arena.allocator(); | |
| 115 | 115 | |
| 116 | 116 | const base_path = blk: { |
| 117 | 117 | const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] }); |
| ... | ... | @@ -162,7 +162,7 @@ test "Dir.Iterator" { |
| 162 | 162 | |
| 163 | 163 | var arena = ArenaAllocator.init(testing.allocator); |
| 164 | 164 | defer arena.deinit(); |
| 165 | const allocator = arena.getAllocator(); | |
| 165 | const allocator = arena.allocator(); | |
| 166 | 166 | |
| 167 | 167 | var entries = std.ArrayList(Dir.Entry).init(allocator); |
| 168 | 168 | |
| ... | ... | @@ -207,7 +207,7 @@ test "Dir.realpath smoke test" { |
| 207 | 207 | |
| 208 | 208 | var arena = ArenaAllocator.init(testing.allocator); |
| 209 | 209 | defer arena.deinit(); |
| 210 | const allocator = arena.getAllocator(); | |
| 210 | const allocator = arena.allocator(); | |
| 211 | 211 | |
| 212 | 212 | const base_path = blk: { |
| 213 | 213 | const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp_dir.sub_path[0..] }); |
| ... | ... | @@ -482,7 +482,7 @@ test "renameAbsolute" { |
| 482 | 482 | // Get base abs path |
| 483 | 483 | var arena = ArenaAllocator.init(testing.allocator); |
| 484 | 484 | defer arena.deinit(); |
| 485 | const allocator = arena.getAllocator(); | |
| 485 | const allocator = arena.allocator(); | |
| 486 | 486 | |
| 487 | 487 | const base_path = blk: { |
| 488 | 488 | const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp_dir.sub_path[0..] }); |
| ... | ... | @@ -993,7 +993,7 @@ test ". and .. in absolute functions" { |
| 993 | 993 | |
| 994 | 994 | var arena = ArenaAllocator.init(testing.allocator); |
| 995 | 995 | defer arena.deinit(); |
| 996 | const allocator = arena.getAllocator(); | |
| 996 | const allocator = arena.allocator(); | |
| 997 | 997 | |
| 998 | 998 | const base_path = blk: { |
| 999 | 999 | const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] }); |
lib/std/hash/benchmark.zig+1-1| ... | ... | @@ -165,7 +165,7 @@ pub fn main() !void { |
| 165 | 165 | |
| 166 | 166 | var buffer: [1024]u8 = undefined; |
| 167 | 167 | var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]); |
| 168 | const args = try std.process.argsAlloc(fixed.getAllocator()); | |
| 168 | const args = try std.process.argsAlloc(fixed.allocator()); | |
| 169 | 169 | |
| 170 | 170 | var filter: ?[]u8 = ""; |
| 171 | 171 | var count: usize = mode(128 * MiB); |
lib/std/heap.zig+20-20| ... | ... | @@ -573,7 +573,7 @@ pub const HeapAllocator = switch (builtin.os.tag) { |
| 573 | 573 | }; |
| 574 | 574 | } |
| 575 | 575 | |
| 576 | pub fn getAllocator(self: *HeapAllocator) Allocator { | |
| 576 | pub fn allocator(self: *HeapAllocator) Allocator { | |
| 577 | 577 | return Allocator.init(self, alloc, resize); |
| 578 | 578 | } |
| 579 | 579 | |
| ... | ... | @@ -680,14 +680,14 @@ pub const FixedBufferAllocator = struct { |
| 680 | 680 | }; |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | /// *WARNING* using this at the same time as the interface returned by `getThreadSafeAllocator` is not thread safe | |
| 684 | pub fn getAllocator(self: *FixedBufferAllocator) Allocator { | |
| 683 | /// *WARNING* using this at the same time as the interface returned by `threadSafeAllocator` is not thread safe | |
| 684 | pub fn allocator(self: *FixedBufferAllocator) Allocator { | |
| 685 | 685 | return Allocator.init(self, alloc, resize); |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | /// Provides a lock free thread safe `Allocator` interface to the underlying `FixedBufferAllocator` |
| 689 | 689 | /// *WARNING* using this at the same time as the interface returned by `getAllocator` is not thread safe |
| 690 | pub fn getThreadSafeAllocator(self: *FixedBufferAllocator) Allocator { | |
| 690 | pub fn threadSafeAllocator(self: *FixedBufferAllocator) Allocator { | |
| 691 | 691 | return Allocator.init(self, threadSafeAlloc, Allocator.NoResize(FixedBufferAllocator).noResize); |
| 692 | 692 | } |
| 693 | 693 | |
| ... | ... | @@ -775,7 +775,7 @@ pub const FixedBufferAllocator = struct { |
| 775 | 775 | } |
| 776 | 776 | }; |
| 777 | 777 | |
| 778 | pub const ThreadSafeFixedBufferAllocator = @compileError("ThreadSafeFixedBufferAllocator has been replaced with `getThreadSafeAllocator` on FixedBufferAllocator"); | |
| 778 | pub const ThreadSafeFixedBufferAllocator = @compileError("ThreadSafeFixedBufferAllocator has been replaced with `threadSafeAllocator` on FixedBufferAllocator"); | |
| 779 | 779 | |
| 780 | 780 | pub fn stackFallback(comptime size: usize, fallback_allocator: Allocator) StackFallbackAllocator(size) { |
| 781 | 781 | return StackFallbackAllocator(size){ |
| ... | ... | @@ -909,7 +909,7 @@ test "HeapAllocator" { |
| 909 | 909 | if (builtin.os.tag == .windows) { |
| 910 | 910 | var heap_allocator = HeapAllocator.init(); |
| 911 | 911 | defer heap_allocator.deinit(); |
| 912 | const allocator = heap_allocator.getAllocator(); | |
| 912 | const allocator = heap_allocator.allocator(); | |
| 913 | 913 | |
| 914 | 914 | try testAllocator(allocator); |
| 915 | 915 | try testAllocatorAligned(allocator); |
| ... | ... | @@ -921,7 +921,7 @@ test "HeapAllocator" { |
| 921 | 921 | test "ArenaAllocator" { |
| 922 | 922 | var arena_allocator = ArenaAllocator.init(page_allocator); |
| 923 | 923 | defer arena_allocator.deinit(); |
| 924 | const allocator = arena_allocator.getAllocator(); | |
| 924 | const allocator = arena_allocator.allocator(); | |
| 925 | 925 | |
| 926 | 926 | try testAllocator(allocator); |
| 927 | 927 | try testAllocatorAligned(allocator); |
| ... | ... | @@ -932,7 +932,7 @@ test "ArenaAllocator" { |
| 932 | 932 | var test_fixed_buffer_allocator_memory: [800000 * @sizeOf(u64)]u8 = undefined; |
| 933 | 933 | test "FixedBufferAllocator" { |
| 934 | 934 | var fixed_buffer_allocator = mem.validationWrap(FixedBufferAllocator.init(test_fixed_buffer_allocator_memory[0..])); |
| 935 | const allocator = fixed_buffer_allocator.getAllocator(); | |
| 935 | const allocator = fixed_buffer_allocator.allocator(); | |
| 936 | 936 | |
| 937 | 937 | try testAllocator(allocator); |
| 938 | 938 | try testAllocatorAligned(allocator); |
| ... | ... | @@ -943,7 +943,7 @@ test "FixedBufferAllocator" { |
| 943 | 943 | test "FixedBufferAllocator.reset" { |
| 944 | 944 | var buf: [8]u8 align(@alignOf(u64)) = undefined; |
| 945 | 945 | var fba = FixedBufferAllocator.init(buf[0..]); |
| 946 | const allocator = fba.getAllocator(); | |
| 946 | const allocator = fba.allocator(); | |
| 947 | 947 | |
| 948 | 948 | const X = 0xeeeeeeeeeeeeeeee; |
| 949 | 949 | const Y = 0xffffffffffffffff; |
| ... | ... | @@ -976,7 +976,7 @@ test "FixedBufferAllocator Reuse memory on realloc" { |
| 976 | 976 | // check if we re-use the memory |
| 977 | 977 | { |
| 978 | 978 | var fixed_buffer_allocator = FixedBufferAllocator.init(small_fixed_buffer[0..]); |
| 979 | const allocator = fixed_buffer_allocator.getAllocator(); | |
| 979 | const allocator = fixed_buffer_allocator.allocator(); | |
| 980 | 980 | |
| 981 | 981 | var slice0 = try allocator.alloc(u8, 5); |
| 982 | 982 | try testing.expect(slice0.len == 5); |
| ... | ... | @@ -988,7 +988,7 @@ test "FixedBufferAllocator Reuse memory on realloc" { |
| 988 | 988 | // check that we don't re-use the memory if it's not the most recent block |
| 989 | 989 | { |
| 990 | 990 | var fixed_buffer_allocator = FixedBufferAllocator.init(small_fixed_buffer[0..]); |
| 991 | const allocator = fixed_buffer_allocator.getAllocator(); | |
| 991 | const allocator = fixed_buffer_allocator.allocator(); | |
| 992 | 992 | |
| 993 | 993 | var slice0 = try allocator.alloc(u8, 2); |
| 994 | 994 | slice0[0] = 1; |
| ... | ... | @@ -1005,16 +1005,16 @@ test "FixedBufferAllocator Reuse memory on realloc" { |
| 1005 | 1005 | test "Thread safe FixedBufferAllocator" { |
| 1006 | 1006 | var fixed_buffer_allocator = FixedBufferAllocator.init(test_fixed_buffer_allocator_memory[0..]); |
| 1007 | 1007 | |
| 1008 | try testAllocator(fixed_buffer_allocator.getThreadSafeAllocator()); | |
| 1009 | try testAllocatorAligned(fixed_buffer_allocator.getThreadSafeAllocator()); | |
| 1010 | try testAllocatorLargeAlignment(fixed_buffer_allocator.getThreadSafeAllocator()); | |
| 1011 | try testAllocatorAlignedShrink(fixed_buffer_allocator.getThreadSafeAllocator()); | |
| 1008 | try testAllocator(fixed_buffer_allocator.threadSafeAllocator()); | |
| 1009 | try testAllocatorAligned(fixed_buffer_allocator.threadSafeAllocator()); | |
| 1010 | try testAllocatorLargeAlignment(fixed_buffer_allocator.threadSafeAllocator()); | |
| 1011 | try testAllocatorAlignedShrink(fixed_buffer_allocator.threadSafeAllocator()); | |
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | 1014 | /// This one should not try alignments that exceed what C malloc can handle. |
| 1015 | 1015 | pub fn testAllocator(base_allocator: mem.Allocator) !void { |
| 1016 | 1016 | var validationAllocator = mem.validationWrap(base_allocator); |
| 1017 | const allocator = validationAllocator.getAllocator(); | |
| 1017 | const allocator = validationAllocator.allocator(); | |
| 1018 | 1018 | |
| 1019 | 1019 | var slice = try allocator.alloc(*i32, 100); |
| 1020 | 1020 | try testing.expect(slice.len == 100); |
| ... | ... | @@ -1060,7 +1060,7 @@ pub fn testAllocator(base_allocator: mem.Allocator) !void { |
| 1060 | 1060 | |
| 1061 | 1061 | pub fn testAllocatorAligned(base_allocator: mem.Allocator) !void { |
| 1062 | 1062 | var validationAllocator = mem.validationWrap(base_allocator); |
| 1063 | const allocator = validationAllocator.getAllocator(); | |
| 1063 | const allocator = validationAllocator.allocator(); | |
| 1064 | 1064 | |
| 1065 | 1065 | // Test a few alignment values, smaller and bigger than the type's one |
| 1066 | 1066 | inline for ([_]u29{ 1, 2, 4, 8, 16, 32, 64 }) |alignment| { |
| ... | ... | @@ -1090,7 +1090,7 @@ pub fn testAllocatorAligned(base_allocator: mem.Allocator) !void { |
| 1090 | 1090 | |
| 1091 | 1091 | pub fn testAllocatorLargeAlignment(base_allocator: mem.Allocator) !void { |
| 1092 | 1092 | var validationAllocator = mem.validationWrap(base_allocator); |
| 1093 | const allocator = validationAllocator.getAllocator(); | |
| 1093 | const allocator = validationAllocator.allocator(); | |
| 1094 | 1094 | |
| 1095 | 1095 | //Maybe a platform's page_size is actually the same as or |
| 1096 | 1096 | // very near usize? |
| ... | ... | @@ -1122,10 +1122,10 @@ pub fn testAllocatorLargeAlignment(base_allocator: mem.Allocator) !void { |
| 1122 | 1122 | |
| 1123 | 1123 | pub fn testAllocatorAlignedShrink(base_allocator: mem.Allocator) !void { |
| 1124 | 1124 | var validationAllocator = mem.validationWrap(base_allocator); |
| 1125 | const allocator = validationAllocator.getAllocator(); | |
| 1125 | const allocator = validationAllocator.allocator(); | |
| 1126 | 1126 | |
| 1127 | 1127 | var debug_buffer: [1000]u8 = undefined; |
| 1128 | const debug_allocator = FixedBufferAllocator.init(&debug_buffer).getAllocator(); | |
| 1128 | const debug_allocator = FixedBufferAllocator.init(&debug_buffer).allocator(); | |
| 1129 | 1129 | |
| 1130 | 1130 | const alloc_size = mem.page_size * 2 + 50; |
| 1131 | 1131 | var slice = try allocator.alignedAlloc(u8, 16, alloc_size); |
lib/std/heap/arena_allocator.zig+1-1| ... | ... | @@ -23,7 +23,7 @@ pub const ArenaAllocator = struct { |
| 23 | 23 | } |
| 24 | 24 | }; |
| 25 | 25 | |
| 26 | pub fn getAllocator(self: *ArenaAllocator) Allocator { | |
| 26 | pub fn allocator(self: *ArenaAllocator) Allocator { | |
| 27 | 27 | return Allocator.init(self, alloc, resize); |
| 28 | 28 | } |
| 29 | 29 |
lib/std/heap/general_purpose_allocator.zig+22-22| ... | ... | @@ -280,7 +280,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 280 | 280 | } |
| 281 | 281 | }; |
| 282 | 282 | |
| 283 | pub fn getAllocator(self: *Self) Allocator { | |
| 283 | pub fn allocator(self: *Self) Allocator { | |
| 284 | 284 | return Allocator.init(self, alloc, resize); |
| 285 | 285 | } |
| 286 | 286 | |
| ... | ... | @@ -830,7 +830,7 @@ const test_config = Config{}; |
| 830 | 830 | test "small allocations - free in same order" { |
| 831 | 831 | var gpa = GeneralPurposeAllocator(test_config){}; |
| 832 | 832 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 833 | const allocator = gpa.getAllocator(); | |
| 833 | const allocator = gpa.allocator(); | |
| 834 | 834 | |
| 835 | 835 | var list = std.ArrayList(*u64).init(std.testing.allocator); |
| 836 | 836 | defer list.deinit(); |
| ... | ... | @@ -849,7 +849,7 @@ test "small allocations - free in same order" { |
| 849 | 849 | test "small allocations - free in reverse order" { |
| 850 | 850 | var gpa = GeneralPurposeAllocator(test_config){}; |
| 851 | 851 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 852 | const allocator = gpa.getAllocator(); | |
| 852 | const allocator = gpa.allocator(); | |
| 853 | 853 | |
| 854 | 854 | var list = std.ArrayList(*u64).init(std.testing.allocator); |
| 855 | 855 | defer list.deinit(); |
| ... | ... | @@ -868,7 +868,7 @@ test "small allocations - free in reverse order" { |
| 868 | 868 | test "large allocations" { |
| 869 | 869 | var gpa = GeneralPurposeAllocator(test_config){}; |
| 870 | 870 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 871 | const allocator = gpa.getAllocator(); | |
| 871 | const allocator = gpa.allocator(); | |
| 872 | 872 | |
| 873 | 873 | const ptr1 = try allocator.alloc(u64, 42768); |
| 874 | 874 | const ptr2 = try allocator.alloc(u64, 52768); |
| ... | ... | @@ -881,7 +881,7 @@ test "large allocations" { |
| 881 | 881 | test "realloc" { |
| 882 | 882 | var gpa = GeneralPurposeAllocator(test_config){}; |
| 883 | 883 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 884 | const allocator = gpa.getAllocator(); | |
| 884 | const allocator = gpa.allocator(); | |
| 885 | 885 | |
| 886 | 886 | var slice = try allocator.alignedAlloc(u8, @alignOf(u32), 1); |
| 887 | 887 | defer allocator.free(slice); |
| ... | ... | @@ -903,7 +903,7 @@ test "realloc" { |
| 903 | 903 | test "shrink" { |
| 904 | 904 | var gpa = GeneralPurposeAllocator(test_config){}; |
| 905 | 905 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 906 | const allocator = gpa.getAllocator(); | |
| 906 | const allocator = gpa.allocator(); | |
| 907 | 907 | |
| 908 | 908 | var slice = try allocator.alloc(u8, 20); |
| 909 | 909 | defer allocator.free(slice); |
| ... | ... | @@ -926,7 +926,7 @@ test "shrink" { |
| 926 | 926 | test "large object - grow" { |
| 927 | 927 | var gpa = GeneralPurposeAllocator(test_config){}; |
| 928 | 928 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 929 | const allocator = gpa.getAllocator(); | |
| 929 | const allocator = gpa.allocator(); | |
| 930 | 930 | |
| 931 | 931 | var slice1 = try allocator.alloc(u8, page_size * 2 - 20); |
| 932 | 932 | defer allocator.free(slice1); |
| ... | ... | @@ -944,7 +944,7 @@ test "large object - grow" { |
| 944 | 944 | test "realloc small object to large object" { |
| 945 | 945 | var gpa = GeneralPurposeAllocator(test_config){}; |
| 946 | 946 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 947 | const allocator = gpa.getAllocator(); | |
| 947 | const allocator = gpa.allocator(); | |
| 948 | 948 | |
| 949 | 949 | var slice = try allocator.alloc(u8, 70); |
| 950 | 950 | defer allocator.free(slice); |
| ... | ... | @@ -961,7 +961,7 @@ test "realloc small object to large object" { |
| 961 | 961 | test "shrink large object to large object" { |
| 962 | 962 | var gpa = GeneralPurposeAllocator(test_config){}; |
| 963 | 963 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 964 | const allocator = gpa.getAllocator(); | |
| 964 | const allocator = gpa.allocator(); | |
| 965 | 965 | |
| 966 | 966 | var slice = try allocator.alloc(u8, page_size * 2 + 50); |
| 967 | 967 | defer allocator.free(slice); |
| ... | ... | @@ -984,10 +984,10 @@ test "shrink large object to large object" { |
| 984 | 984 | test "shrink large object to large object with larger alignment" { |
| 985 | 985 | var gpa = GeneralPurposeAllocator(test_config){}; |
| 986 | 986 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 987 | const allocator = gpa.getAllocator(); | |
| 987 | const allocator = gpa.allocator(); | |
| 988 | 988 | |
| 989 | 989 | var debug_buffer: [1000]u8 = undefined; |
| 990 | const debug_allocator = std.heap.FixedBufferAllocator.init(&debug_buffer).getAllocator(); | |
| 990 | const debug_allocator = std.heap.FixedBufferAllocator.init(&debug_buffer).allocator(); | |
| 991 | 991 | |
| 992 | 992 | const alloc_size = page_size * 2 + 50; |
| 993 | 993 | var slice = try allocator.alignedAlloc(u8, 16, alloc_size); |
| ... | ... | @@ -1019,7 +1019,7 @@ test "shrink large object to large object with larger alignment" { |
| 1019 | 1019 | test "realloc large object to small object" { |
| 1020 | 1020 | var gpa = GeneralPurposeAllocator(test_config){}; |
| 1021 | 1021 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 1022 | const allocator = gpa.getAllocator(); | |
| 1022 | const allocator = gpa.allocator(); | |
| 1023 | 1023 | |
| 1024 | 1024 | var slice = try allocator.alloc(u8, page_size * 2 + 50); |
| 1025 | 1025 | defer allocator.free(slice); |
| ... | ... | @@ -1037,7 +1037,7 @@ test "overrideable mutexes" { |
| 1037 | 1037 | .mutex = std.Thread.Mutex{}, |
| 1038 | 1038 | }; |
| 1039 | 1039 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 1040 | const allocator = gpa.getAllocator(); | |
| 1040 | const allocator = gpa.allocator(); | |
| 1041 | 1041 | |
| 1042 | 1042 | const ptr = try allocator.create(i32); |
| 1043 | 1043 | defer allocator.destroy(ptr); |
| ... | ... | @@ -1046,7 +1046,7 @@ test "overrideable mutexes" { |
| 1046 | 1046 | test "non-page-allocator backing allocator" { |
| 1047 | 1047 | var gpa = GeneralPurposeAllocator(.{}){ .backing_allocator = std.testing.allocator }; |
| 1048 | 1048 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 1049 | const allocator = gpa.getAllocator(); | |
| 1049 | const allocator = gpa.allocator(); | |
| 1050 | 1050 | |
| 1051 | 1051 | const ptr = try allocator.create(i32); |
| 1052 | 1052 | defer allocator.destroy(ptr); |
| ... | ... | @@ -1055,10 +1055,10 @@ test "non-page-allocator backing allocator" { |
| 1055 | 1055 | test "realloc large object to larger alignment" { |
| 1056 | 1056 | var gpa = GeneralPurposeAllocator(test_config){}; |
| 1057 | 1057 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 1058 | const allocator = gpa.getAllocator(); | |
| 1058 | const allocator = gpa.allocator(); | |
| 1059 | 1059 | |
| 1060 | 1060 | var debug_buffer: [1000]u8 = undefined; |
| 1061 | const debug_allocator = std.heap.FixedBufferAllocator.init(&debug_buffer).getAllocator(); | |
| 1061 | const debug_allocator = std.heap.FixedBufferAllocator.init(&debug_buffer).allocator(); | |
| 1062 | 1062 | |
| 1063 | 1063 | var slice = try allocator.alignedAlloc(u8, 16, page_size * 2 + 50); |
| 1064 | 1064 | defer allocator.free(slice); |
| ... | ... | @@ -1094,9 +1094,9 @@ test "realloc large object to larger alignment" { |
| 1094 | 1094 | |
| 1095 | 1095 | test "large object shrinks to small but allocation fails during shrink" { |
| 1096 | 1096 | var failing_allocator = std.testing.FailingAllocator.init(std.heap.page_allocator, 3); |
| 1097 | var gpa = GeneralPurposeAllocator(.{}){ .backing_allocator = failing_allocator.getAllocator() }; | |
| 1097 | var gpa = GeneralPurposeAllocator(.{}){ .backing_allocator = failing_allocator.allocator() }; | |
| 1098 | 1098 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 1099 | const allocator = gpa.getAllocator(); | |
| 1099 | const allocator = gpa.allocator(); | |
| 1100 | 1100 | |
| 1101 | 1101 | var slice = try allocator.alloc(u8, page_size * 2 + 50); |
| 1102 | 1102 | defer allocator.free(slice); |
| ... | ... | @@ -1113,7 +1113,7 @@ test "large object shrinks to small but allocation fails during shrink" { |
| 1113 | 1113 | test "objects of size 1024 and 2048" { |
| 1114 | 1114 | var gpa = GeneralPurposeAllocator(test_config){}; |
| 1115 | 1115 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 1116 | const allocator = gpa.getAllocator(); | |
| 1116 | const allocator = gpa.allocator(); | |
| 1117 | 1117 | |
| 1118 | 1118 | const slice = try allocator.alloc(u8, 1025); |
| 1119 | 1119 | const slice2 = try allocator.alloc(u8, 3000); |
| ... | ... | @@ -1125,7 +1125,7 @@ test "objects of size 1024 and 2048" { |
| 1125 | 1125 | test "setting a memory cap" { |
| 1126 | 1126 | var gpa = GeneralPurposeAllocator(.{ .enable_memory_limit = true }){}; |
| 1127 | 1127 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 1128 | const allocator = gpa.getAllocator(); | |
| 1128 | const allocator = gpa.allocator(); | |
| 1129 | 1129 | |
| 1130 | 1130 | gpa.setRequestedMemoryLimit(1010); |
| 1131 | 1131 | |
| ... | ... | @@ -1154,9 +1154,9 @@ test "double frees" { |
| 1154 | 1154 | defer std.testing.expect(!backing_gpa.deinit()) catch @panic("leak"); |
| 1155 | 1155 | |
| 1156 | 1156 | const GPA = GeneralPurposeAllocator(.{ .safety = true, .never_unmap = true, .retain_metadata = true }); |
| 1157 | var gpa = GPA{ .backing_allocator = backing_gpa.getAllocator() }; | |
| 1157 | var gpa = GPA{ .backing_allocator = backing_gpa.allocator() }; | |
| 1158 | 1158 | defer std.testing.expect(!gpa.deinit()) catch @panic("leak"); |
| 1159 | const allocator = gpa.getAllocator(); | |
| 1159 | const allocator = gpa.allocator(); | |
| 1160 | 1160 | |
| 1161 | 1161 | // detect a small allocation double free, even though bucket is emptied |
| 1162 | 1162 | const index: usize = 6; |
lib/std/heap/log_to_writer_allocator.zig+2-2| ... | ... | @@ -17,7 +17,7 @@ pub fn LogToWriterAllocator(comptime Writer: type) type { |
| 17 | 17 | }; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | pub fn getAllocator(self: *Self) Allocator { | |
| 20 | pub fn allocator(self: *Self) Allocator { | |
| 21 | 21 | return Allocator.init(self, alloc, resize); |
| 22 | 22 | } |
| 23 | 23 | |
| ... | ... | @@ -82,7 +82,7 @@ test "LogToWriterAllocator" { |
| 82 | 82 | |
| 83 | 83 | var allocator_buf: [10]u8 = undefined; |
| 84 | 84 | var fixedBufferAllocator = std.mem.validationWrap(std.heap.FixedBufferAllocator.init(&allocator_buf)); |
| 85 | const allocator = logToWriterAllocator(fixedBufferAllocator.getAllocator(), fbs.writer()).getAllocator(); | |
| 85 | const allocator = logToWriterAllocator(fixedBufferAllocator.allocator(), fbs.writer()).allocator(); | |
| 86 | 86 | |
| 87 | 87 | var a = try allocator.alloc(u8, 10); |
| 88 | 88 | a = allocator.shrink(a, 5); |
lib/std/heap/logging_allocator.zig+1-1| ... | ... | @@ -32,7 +32,7 @@ pub fn ScopedLoggingAllocator( |
| 32 | 32 | }; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | pub fn getAllocator(self: *Self) Allocator { | |
| 35 | pub fn allocator(self: *Self) Allocator { | |
| 36 | 36 | return Allocator.init(self, alloc, resize); |
| 37 | 37 | } |
| 38 | 38 |
lib/std/json.zig+7-7| ... | ... | @@ -2033,7 +2033,7 @@ test "parse into tagged union" { |
| 2033 | 2033 | |
| 2034 | 2034 | { // failing allocations should be bubbled up instantly without trying next member |
| 2035 | 2035 | var fail_alloc = testing.FailingAllocator.init(testing.allocator, 0); |
| 2036 | const options = ParseOptions{ .allocator = fail_alloc.getAllocator() }; | |
| 2036 | const options = ParseOptions{ .allocator = fail_alloc.allocator() }; | |
| 2037 | 2037 | const T = union(enum) { |
| 2038 | 2038 | // both fields here match the input |
| 2039 | 2039 | string: []const u8, |
| ... | ... | @@ -2081,7 +2081,7 @@ test "parse union bubbles up AllocatorRequired" { |
| 2081 | 2081 | |
| 2082 | 2082 | test "parseFree descends into tagged union" { |
| 2083 | 2083 | var fail_alloc = testing.FailingAllocator.init(testing.allocator, 1); |
| 2084 | const options = ParseOptions{ .allocator = fail_alloc.getAllocator() }; | |
| 2084 | const options = ParseOptions{ .allocator = fail_alloc.allocator() }; | |
| 2085 | 2085 | const T = union(enum) { |
| 2086 | 2086 | int: i32, |
| 2087 | 2087 | float: f64, |
| ... | ... | @@ -2364,7 +2364,7 @@ pub const Parser = struct { |
| 2364 | 2364 | |
| 2365 | 2365 | var arena = ArenaAllocator.init(p.allocator); |
| 2366 | 2366 | errdefer arena.deinit(); |
| 2367 | const allocator = arena.getAllocator(); | |
| 2367 | const allocator = arena.allocator(); | |
| 2368 | 2368 | |
| 2369 | 2369 | while (try s.next()) |token| { |
| 2370 | 2370 | try p.transition(allocator, input, s.i - 1, token); |
| ... | ... | @@ -2746,13 +2746,13 @@ fn testParse(arena_allocator: std.mem.Allocator, json_str: []const u8) !Value { |
| 2746 | 2746 | test "parsing empty string gives appropriate error" { |
| 2747 | 2747 | var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator); |
| 2748 | 2748 | defer arena_allocator.deinit(); |
| 2749 | try testing.expectError(error.UnexpectedEndOfJson, testParse(arena_allocator.getAllocator(), "")); | |
| 2749 | try testing.expectError(error.UnexpectedEndOfJson, testParse(arena_allocator.allocator(), "")); | |
| 2750 | 2750 | } |
| 2751 | 2751 | |
| 2752 | 2752 | test "integer after float has proper type" { |
| 2753 | 2753 | var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator); |
| 2754 | 2754 | defer arena_allocator.deinit(); |
| 2755 | const json = try testParse(arena_allocator.getAllocator(), | |
| 2755 | const json = try testParse(arena_allocator.allocator(), | |
| 2756 | 2756 | \\{ |
| 2757 | 2757 | \\ "float": 3.14, |
| 2758 | 2758 | \\ "ints": [1, 2, 3] |
| ... | ... | @@ -2787,7 +2787,7 @@ test "escaped characters" { |
| 2787 | 2787 | \\} |
| 2788 | 2788 | ; |
| 2789 | 2789 | |
| 2790 | const obj = (try testParse(arena_allocator.getAllocator(), input)).Object; | |
| 2790 | const obj = (try testParse(arena_allocator.allocator(), input)).Object; | |
| 2791 | 2791 | |
| 2792 | 2792 | try testing.expectEqualSlices(u8, obj.get("backslash").?.String, "\\"); |
| 2793 | 2793 | try testing.expectEqualSlices(u8, obj.get("forwardslash").?.String, "/"); |
| ... | ... | @@ -2813,7 +2813,7 @@ test "string copy option" { |
| 2813 | 2813 | |
| 2814 | 2814 | var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator); |
| 2815 | 2815 | defer arena_allocator.deinit(); |
| 2816 | const allocator = arena_allocator.getAllocator(); | |
| 2816 | const allocator = arena_allocator.allocator(); | |
| 2817 | 2817 | |
| 2818 | 2818 | const tree_nocopy = try Parser.init(allocator, false).parse(input); |
| 2819 | 2819 | const obj_nocopy = tree_nocopy.root.Object; |
lib/std/json/write_stream.zig+1-1| ... | ... | @@ -243,7 +243,7 @@ test "json write stream" { |
| 243 | 243 | try w.beginObject(); |
| 244 | 244 | |
| 245 | 245 | try w.objectField("object"); |
| 246 | try w.emitJson(try getJsonObject(arena_allocator.getAllocator())); | |
| 246 | try w.emitJson(try getJsonObject(arena_allocator.allocator())); | |
| 247 | 247 | |
| 248 | 248 | try w.objectField("string"); |
| 249 | 249 | try w.emitString("This is a string"); |
lib/std/mem.zig+2-2| ... | ... | @@ -46,13 +46,13 @@ pub fn ValidationAllocator(comptime T: type) type { |
| 46 | 46 | }; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | pub fn getAllocator(self: *Self) Allocator { | |
| 49 | pub fn allocator(self: *Self) Allocator { | |
| 50 | 50 | return Allocator.init(self, alloc, resize); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | fn getUnderlyingAllocatorPtr(self: *Self) Allocator { |
| 54 | 54 | if (T == Allocator) return self.underlying_allocator; |
| 55 | return self.underlying_allocator.getAllocator(); | |
| 55 | return self.underlying_allocator.allocator(); | |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | pub fn alloc( |
lib/std/net.zig+2-2| ... | ... | @@ -704,7 +704,7 @@ pub fn getAddressList(allocator: mem.Allocator, name: []const u8, port: u16) !*A |
| 704 | 704 | var arena = std.heap.ArenaAllocator.init(allocator); |
| 705 | 705 | errdefer arena.deinit(); |
| 706 | 706 | |
| 707 | const result = try arena.getAllocator().create(AddressList); | |
| 707 | const result = try arena.allocator().create(AddressList); | |
| 708 | 708 | result.* = AddressList{ |
| 709 | 709 | .arena = arena, |
| 710 | 710 | .addrs = undefined, |
| ... | ... | @@ -712,7 +712,7 @@ pub fn getAddressList(allocator: mem.Allocator, name: []const u8, port: u16) !*A |
| 712 | 712 | }; |
| 713 | 713 | break :blk result; |
| 714 | 714 | }; |
| 715 | const arena = result.arena.getAllocator(); | |
| 715 | const arena = result.arena.allocator(); | |
| 716 | 716 | errdefer result.arena.deinit(); |
| 717 | 717 | |
| 718 | 718 | if (builtin.target.os.tag == .windows or builtin.link_libc) { |
lib/std/os/test.zig+1-1| ... | ... | @@ -58,7 +58,7 @@ test "open smoke test" { |
| 58 | 58 | // Get base abs path |
| 59 | 59 | var arena = ArenaAllocator.init(testing.allocator); |
| 60 | 60 | defer arena.deinit(); |
| 61 | const allocator = arena.getAllocator(); | |
| 61 | const allocator = arena.allocator(); | |
| 62 | 62 | |
| 63 | 63 | const base_path = blk: { |
| 64 | 64 | const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] }); |
lib/std/process.zig+1-1| ... | ... | @@ -854,7 +854,7 @@ pub fn execve( |
| 854 | 854 | |
| 855 | 855 | var arena_allocator = std.heap.ArenaAllocator.init(allocator); |
| 856 | 856 | defer arena_allocator.deinit(); |
| 857 | const arena = arena_allocator.getAllocator(); | |
| 857 | const arena = arena_allocator.allocator(); | |
| 858 | 858 | |
| 859 | 859 | const argv_buf = try arena.allocSentinel(?[*:0]u8, argv.len, null); |
| 860 | 860 | for (argv) |arg, i| argv_buf[i] = (try arena.dupeZ(u8, arg)).ptr; |
lib/std/special/build_runner.zig+1-1| ... | ... | @@ -16,7 +16,7 @@ pub fn main() !void { |
| 16 | 16 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 17 | 17 | defer arena.deinit(); |
| 18 | 18 | |
| 19 | const allocator = arena.getAllocator(); | |
| 19 | const allocator = arena.allocator(); | |
| 20 | 20 | var args = try process.argsAlloc(allocator); |
| 21 | 21 | defer process.argsFree(allocator, args); |
| 22 | 22 |
lib/std/special/test_runner.zig+1-1| ... | ... | @@ -10,7 +10,7 @@ var args_buffer: [std.fs.MAX_PATH_BYTES + std.mem.page_size]u8 = undefined; |
| 10 | 10 | var args_allocator = std.heap.FixedBufferAllocator.init(&args_buffer); |
| 11 | 11 | |
| 12 | 12 | fn processArgs() void { |
| 13 | const args = std.process.argsAlloc(args_allocator.getAllocator()) catch { | |
| 13 | const args = std.process.argsAlloc(args_allocator.allocator()) catch { | |
| 14 | 14 | @panic("Too many bytes passed over the CLI to the test runner"); |
| 15 | 15 | }; |
| 16 | 16 | if (args.len != 2) { |
lib/std/testing.zig+3-3| ... | ... | @@ -7,11 +7,11 @@ const print = std.debug.print; |
| 7 | 7 | pub const FailingAllocator = @import("testing/failing_allocator.zig").FailingAllocator; |
| 8 | 8 | |
| 9 | 9 | /// This should only be used in temporary test programs. |
| 10 | pub const allocator = allocator_instance.getAllocator(); | |
| 10 | pub const allocator = allocator_instance.allocator(); | |
| 11 | 11 | pub var allocator_instance = std.heap.GeneralPurposeAllocator(.{}){}; |
| 12 | 12 | |
| 13 | pub const failing_allocator = failing_allocator_instance.getAllocator(); | |
| 14 | pub var failing_allocator_instance = FailingAllocator.init(base_allocator_instance.getAllocator(), 0); | |
| 13 | pub const failing_allocator = failing_allocator_instance.allocator(); | |
| 14 | pub var failing_allocator_instance = FailingAllocator.init(base_allocator_instance.allocator(), 0); | |
| 15 | 15 | |
| 16 | 16 | pub var base_allocator_instance = std.heap.FixedBufferAllocator.init(""); |
| 17 | 17 |
lib/std/testing/failing_allocator.zig+1-1| ... | ... | @@ -40,7 +40,7 @@ pub const FailingAllocator = struct { |
| 40 | 40 | }; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | pub fn getAllocator(self: *FailingAllocator) mem.Allocator { | |
| 43 | pub fn allocator(self: *FailingAllocator) mem.Allocator { | |
| 44 | 44 | return mem.Allocator.init(self, alloc, resize); |
| 45 | 45 | } |
| 46 | 46 |
lib/std/zig/parser_test.zig+4-4| ... | ... | @@ -5351,8 +5351,8 @@ fn testTransform(source: [:0]const u8, expected_source: []const u8) !void { |
| 5351 | 5351 | const needed_alloc_count = x: { |
| 5352 | 5352 | // Try it once with unlimited memory, make sure it works |
| 5353 | 5353 | var fixed_allocator = std.heap.FixedBufferAllocator.init(fixed_buffer_mem[0..]); |
| 5354 | var failing_allocator = std.testing.FailingAllocator.init(fixed_allocator.getAllocator(), maxInt(usize)); | |
| 5355 | const allocator = failing_allocator.getAllocator(); | |
| 5354 | var failing_allocator = std.testing.FailingAllocator.init(fixed_allocator.allocator(), maxInt(usize)); | |
| 5355 | const allocator = failing_allocator.allocator(); | |
| 5356 | 5356 | var anything_changed: bool = undefined; |
| 5357 | 5357 | const result_source = try testParse(source, allocator, &anything_changed); |
| 5358 | 5358 | try std.testing.expectEqualStrings(expected_source, result_source); |
| ... | ... | @@ -5369,9 +5369,9 @@ fn testTransform(source: [:0]const u8, expected_source: []const u8) !void { |
| 5369 | 5369 | var fail_index: usize = 0; |
| 5370 | 5370 | while (fail_index < needed_alloc_count) : (fail_index += 1) { |
| 5371 | 5371 | var fixed_allocator = std.heap.FixedBufferAllocator.init(fixed_buffer_mem[0..]); |
| 5372 | var failing_allocator = std.testing.FailingAllocator.init(fixed_allocator.getAllocator(), fail_index); | |
| 5372 | var failing_allocator = std.testing.FailingAllocator.init(fixed_allocator.allocator(), fail_index); | |
| 5373 | 5373 | var anything_changed: bool = undefined; |
| 5374 | if (testParse(source, failing_allocator.getAllocator(), &anything_changed)) |_| { | |
| 5374 | if (testParse(source, failing_allocator.allocator(), &anything_changed)) |_| { | |
| 5375 | 5375 | return error.NondeterministicMemoryUsage; |
| 5376 | 5376 | } else |err| switch (err) { |
| 5377 | 5377 | error.OutOfMemory => { |
lib/std/zig/perf_test.zig+1-1| ... | ... | @@ -33,7 +33,7 @@ pub fn main() !void { |
| 33 | 33 | |
| 34 | 34 | fn testOnce() usize { |
| 35 | 35 | var fixed_buf_alloc = std.heap.FixedBufferAllocator.init(fixed_buffer_mem[0..]); |
| 36 | var allocator = fixed_buf_alloc.getAllocator(); | |
| 36 | var allocator = fixed_buf_alloc.allocator(); | |
| 37 | 37 | _ = std.zig.parse(allocator, source) catch @panic("parse failure"); |
| 38 | 38 | return fixed_buf_alloc.end_index; |
| 39 | 39 | } |
lib/std/zig/string_literal.zig+1-1| ... | ... | @@ -147,7 +147,7 @@ test "parse" { |
| 147 | 147 | |
| 148 | 148 | var fixed_buf_mem: [32]u8 = undefined; |
| 149 | 149 | var fixed_buf_alloc = std.heap.FixedBufferAllocator.init(fixed_buf_mem[0..]); |
| 150 | var alloc = fixed_buf_alloc.getAllocator(); | |
| 150 | var alloc = fixed_buf_alloc.allocator(); | |
| 151 | 151 | |
| 152 | 152 | try expect(eql(u8, "foo", try parseAlloc(alloc, "\"foo\""))); |
| 153 | 153 | try expect(eql(u8, "foo", try parseAlloc(alloc, "\"f\x6f\x6f\""))); |
src/AstGen.zig+2-2| ... | ... | @@ -98,7 +98,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { |
| 98 | 98 | |
| 99 | 99 | var astgen: AstGen = .{ |
| 100 | 100 | .gpa = gpa, |
| 101 | .arena = arena.getAllocator(), | |
| 101 | .arena = arena.allocator(), | |
| 102 | 102 | .tree = &tree, |
| 103 | 103 | }; |
| 104 | 104 | defer astgen.deinit(gpa); |
| ... | ... | @@ -1939,7 +1939,7 @@ fn blockExprStmts(gz: *GenZir, parent_scope: *Scope, statements: []const Ast.Nod |
| 1939 | 1939 | |
| 1940 | 1940 | var block_arena = std.heap.ArenaAllocator.init(gz.astgen.gpa); |
| 1941 | 1941 | defer block_arena.deinit(); |
| 1942 | const block_arena_allocator = block_arena.getAllocator(); | |
| 1942 | const block_arena_allocator = block_arena.allocator(); | |
| 1943 | 1943 | |
| 1944 | 1944 | var noreturn_src_node: Ast.Node.Index = 0; |
| 1945 | 1945 | var scope = parent_scope; |
src/Compilation.zig+12-12| ... | ... | @@ -412,7 +412,7 @@ pub const AllErrors = struct { |
| 412 | 412 | errors: *std.ArrayList(Message), |
| 413 | 413 | module_err_msg: Module.ErrorMsg, |
| 414 | 414 | ) !void { |
| 415 | const allocator = arena.getAllocator(); | |
| 415 | const allocator = arena.allocator(); | |
| 416 | 416 | const notes = try allocator.alloc(Message, module_err_msg.notes.len); |
| 417 | 417 | for (notes) |*note, i| { |
| 418 | 418 | const module_note = module_err_msg.notes[i]; |
| ... | ... | @@ -549,7 +549,7 @@ pub const AllErrors = struct { |
| 549 | 549 | msg: []const u8, |
| 550 | 550 | optional_children: ?AllErrors, |
| 551 | 551 | ) !void { |
| 552 | const allocator = arena.getAllocator(); | |
| 552 | const allocator = arena.allocator(); | |
| 553 | 553 | const duped_msg = try allocator.dupe(u8, msg); |
| 554 | 554 | if (optional_children) |*children| { |
| 555 | 555 | try errors.append(.{ .plain = .{ |
| ... | ... | @@ -788,7 +788,7 @@ fn addPackageTableToCacheHash( |
| 788 | 788 | seen_table: *std.AutoHashMap(*Package, void), |
| 789 | 789 | hash_type: union(enum) { path_bytes, files: *Cache.Manifest }, |
| 790 | 790 | ) (error{OutOfMemory} || std.os.GetCwdError)!void { |
| 791 | const allocator = arena.getAllocator(); | |
| 791 | const allocator = arena.allocator(); | |
| 792 | 792 | |
| 793 | 793 | const packages = try allocator.alloc(Package.Table.KV, pkg_table.count()); |
| 794 | 794 | { |
| ... | ... | @@ -852,7 +852,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 852 | 852 | // initialization and then is freed in deinit(). |
| 853 | 853 | var arena_allocator = std.heap.ArenaAllocator.init(gpa); |
| 854 | 854 | errdefer arena_allocator.deinit(); |
| 855 | const arena = arena_allocator.getAllocator(); | |
| 855 | const arena = arena_allocator.allocator(); | |
| 856 | 856 | |
| 857 | 857 | // We put the `Compilation` itself in the arena. Freeing the arena will free the module. |
| 858 | 858 | // It's initialized later after we prepare the initialization options. |
| ... | ... | @@ -1210,7 +1210,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1210 | 1210 | { |
| 1211 | 1211 | var local_arena = std.heap.ArenaAllocator.init(gpa); |
| 1212 | 1212 | defer local_arena.deinit(); |
| 1213 | var seen_table = std.AutoHashMap(*Package, void).init(local_arena.getAllocator()); | |
| 1213 | var seen_table = std.AutoHashMap(*Package, void).init(local_arena.allocator()); | |
| 1214 | 1214 | try addPackageTableToCacheHash(&hash, &local_arena, main_pkg.table, &seen_table, .path_bytes); |
| 1215 | 1215 | } |
| 1216 | 1216 | hash.add(valgrind); |
| ... | ... | @@ -2013,7 +2013,7 @@ pub fn totalErrorCount(self: *Compilation) usize { |
| 2013 | 2013 | pub fn getAllErrorsAlloc(self: *Compilation) !AllErrors { |
| 2014 | 2014 | var arena = std.heap.ArenaAllocator.init(self.gpa); |
| 2015 | 2015 | errdefer arena.deinit(); |
| 2016 | const arena_allocator = arena.getAllocator(); | |
| 2016 | const arena_allocator = arena.allocator(); | |
| 2017 | 2017 | |
| 2018 | 2018 | var errors = std.ArrayList(AllErrors.Message).init(self.gpa); |
| 2019 | 2019 | defer errors.deinit(); |
| ... | ... | @@ -2295,7 +2295,7 @@ fn processOneJob(comp: *Compilation, job: Job, main_progress_node: *std.Progress |
| 2295 | 2295 | |
| 2296 | 2296 | var tmp_arena = std.heap.ArenaAllocator.init(gpa); |
| 2297 | 2297 | defer tmp_arena.deinit(); |
| 2298 | const sema_arena = tmp_arena.getAllocator(); | |
| 2298 | const sema_arena = tmp_arena.allocator(); | |
| 2299 | 2299 | |
| 2300 | 2300 | const sema_frame = tracy.namedFrame("sema"); |
| 2301 | 2301 | var sema_frame_ended = false; |
| ... | ... | @@ -2390,7 +2390,7 @@ fn processOneJob(comp: *Compilation, job: Job, main_progress_node: *std.Progress |
| 2390 | 2390 | .decl = decl, |
| 2391 | 2391 | .fwd_decl = fwd_decl.toManaged(gpa), |
| 2392 | 2392 | .typedefs = c_codegen.TypedefMap.init(gpa), |
| 2393 | .typedefs_arena = typedefs_arena.getAllocator(), | |
| 2393 | .typedefs_arena = typedefs_arena.allocator(), | |
| 2394 | 2394 | }; |
| 2395 | 2395 | defer dg.fwd_decl.deinit(); |
| 2396 | 2396 | defer dg.typedefs.deinit(); |
| ... | ... | @@ -2844,7 +2844,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult { |
| 2844 | 2844 | const digest = if (!actual_hit) digest: { |
| 2845 | 2845 | var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa); |
| 2846 | 2846 | defer arena_allocator.deinit(); |
| 2847 | const arena = arena_allocator.getAllocator(); | |
| 2847 | const arena = arena_allocator.allocator(); | |
| 2848 | 2848 | |
| 2849 | 2849 | const tmp_digest = man.hash.peek(); |
| 2850 | 2850 | const tmp_dir_sub_path = try std.fs.path.join(arena, &[_][]const u8{ "o", &tmp_digest }); |
| ... | ... | @@ -3099,7 +3099,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: *std.P |
| 3099 | 3099 | |
| 3100 | 3100 | var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa); |
| 3101 | 3101 | defer arena_allocator.deinit(); |
| 3102 | const arena = arena_allocator.getAllocator(); | |
| 3102 | const arena = arena_allocator.allocator(); | |
| 3103 | 3103 | |
| 3104 | 3104 | const c_source_basename = std.fs.path.basename(c_object.src.src_path); |
| 3105 | 3105 | |
| ... | ... | @@ -4420,7 +4420,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node |
| 4420 | 4420 | |
| 4421 | 4421 | var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa); |
| 4422 | 4422 | defer arena_allocator.deinit(); |
| 4423 | const arena = arena_allocator.getAllocator(); | |
| 4423 | const arena = arena_allocator.allocator(); | |
| 4424 | 4424 | |
| 4425 | 4425 | // Here we use the legacy stage1 C++ compiler to compile Zig code. |
| 4426 | 4426 | const mod = comp.bin_file.options.module.?; |
| ... | ... | @@ -4457,7 +4457,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node |
| 4457 | 4457 | |
| 4458 | 4458 | _ = try man.addFile(main_zig_file, null); |
| 4459 | 4459 | { |
| 4460 | var seen_table = std.AutoHashMap(*Package, void).init(arena_allocator.getAllocator()); | |
| 4460 | var seen_table = std.AutoHashMap(*Package, void).init(arena_allocator.allocator()); | |
| 4461 | 4461 | try addPackageTableToCacheHash(&man.hash, &arena_allocator, mod.main_pkg.table, &seen_table, .{ .files = &man }); |
| 4462 | 4462 | } |
| 4463 | 4463 | man.hash.add(comp.bin_file.options.valgrind); |
src/DepTokenizer.zig+1-1| ... | ... | @@ -878,7 +878,7 @@ test "error prereq - continuation expecting end-of-line" { |
| 878 | 878 | // - tokenize input, emit textual representation, and compare to expect |
| 879 | 879 | fn depTokenizer(input: []const u8, expect: []const u8) !void { |
| 880 | 880 | var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator); |
| 881 | const arena = arena_allocator.getAllocator(); | |
| 881 | const arena = arena_allocator.allocator(); | |
| 882 | 882 | defer arena_allocator.deinit(); |
| 883 | 883 | |
| 884 | 884 | var it: Tokenizer = .{ .bytes = input }; |
src/Module.zig+8-8| ... | ... | @@ -517,7 +517,7 @@ pub const Decl = struct { |
| 517 | 517 | |
| 518 | 518 | pub fn finalizeNewArena(decl: *Decl, arena: *std.heap.ArenaAllocator) !void { |
| 519 | 519 | assert(decl.value_arena == null); |
| 520 | const arena_state = try arena.getAllocator().create(std.heap.ArenaAllocator.State); | |
| 520 | const arena_state = try arena.allocator().create(std.heap.ArenaAllocator.State); | |
| 521 | 521 | arena_state.* = arena.state; |
| 522 | 522 | decl.value_arena = arena_state; |
| 523 | 523 | } |
| ... | ... | @@ -3159,7 +3159,7 @@ pub fn semaFile(mod: *Module, file: *File) SemaError!void { |
| 3159 | 3159 | const gpa = mod.gpa; |
| 3160 | 3160 | var new_decl_arena = std.heap.ArenaAllocator.init(gpa); |
| 3161 | 3161 | errdefer new_decl_arena.deinit(); |
| 3162 | const new_decl_arena_allocator = new_decl_arena.getAllocator(); | |
| 3162 | const new_decl_arena_allocator = new_decl_arena.allocator(); | |
| 3163 | 3163 | |
| 3164 | 3164 | const struct_obj = try new_decl_arena_allocator.create(Module.Struct); |
| 3165 | 3165 | const struct_ty = try Type.Tag.@"struct".create(new_decl_arena_allocator, struct_obj); |
| ... | ... | @@ -3203,7 +3203,7 @@ pub fn semaFile(mod: *Module, file: *File) SemaError!void { |
| 3203 | 3203 | |
| 3204 | 3204 | var sema_arena = std.heap.ArenaAllocator.init(gpa); |
| 3205 | 3205 | defer sema_arena.deinit(); |
| 3206 | const sema_arena_allocator = sema_arena.getAllocator(); | |
| 3206 | const sema_arena_allocator = sema_arena.allocator(); | |
| 3207 | 3207 | |
| 3208 | 3208 | var sema: Sema = .{ |
| 3209 | 3209 | .mod = mod, |
| ... | ... | @@ -3267,11 +3267,11 @@ fn semaDecl(mod: *Module, decl: *Decl) !bool { |
| 3267 | 3267 | // We need the memory for the Type to go into the arena for the Decl |
| 3268 | 3268 | var decl_arena = std.heap.ArenaAllocator.init(gpa); |
| 3269 | 3269 | errdefer decl_arena.deinit(); |
| 3270 | const decl_arena_allocator = decl_arena.getAllocator(); | |
| 3270 | const decl_arena_allocator = decl_arena.allocator(); | |
| 3271 | 3271 | |
| 3272 | 3272 | var analysis_arena = std.heap.ArenaAllocator.init(gpa); |
| 3273 | 3273 | defer analysis_arena.deinit(); |
| 3274 | const analysis_arena_allocator = analysis_arena.getAllocator(); | |
| 3274 | const analysis_arena_allocator = analysis_arena.allocator(); | |
| 3275 | 3275 | |
| 3276 | 3276 | var sema: Sema = .{ |
| 3277 | 3277 | .mod = mod, |
| ... | ... | @@ -4132,7 +4132,7 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn, arena: Allocator) Sem |
| 4132 | 4132 | // Use the Decl's arena for captured values. |
| 4133 | 4133 | var decl_arena = decl.value_arena.?.promote(gpa); |
| 4134 | 4134 | defer decl.value_arena.?.* = decl_arena.state; |
| 4135 | const decl_arena_allocator = decl_arena.getAllocator(); | |
| 4135 | const decl_arena_allocator = decl_arena.allocator(); | |
| 4136 | 4136 | |
| 4137 | 4137 | var sema: Sema = .{ |
| 4138 | 4138 | .mod = mod, |
| ... | ... | @@ -4756,7 +4756,7 @@ pub fn populateTestFunctions(mod: *Module) !void { |
| 4756 | 4756 | // decl reference it as a slice. |
| 4757 | 4757 | var new_decl_arena = std.heap.ArenaAllocator.init(gpa); |
| 4758 | 4758 | errdefer new_decl_arena.deinit(); |
| 4759 | const arena = new_decl_arena.getAllocator(); | |
| 4759 | const arena = new_decl_arena.allocator(); | |
| 4760 | 4760 | |
| 4761 | 4761 | const test_fn_vals = try arena.alloc(Value, mod.test_functions.count()); |
| 4762 | 4762 | const array_decl = try mod.createAnonymousDeclFromDecl(decl, decl.src_namespace, null, .{ |
| ... | ... | @@ -4807,7 +4807,7 @@ pub fn populateTestFunctions(mod: *Module) !void { |
| 4807 | 4807 | { |
| 4808 | 4808 | var new_decl_arena = std.heap.ArenaAllocator.init(gpa); |
| 4809 | 4809 | errdefer new_decl_arena.deinit(); |
| 4810 | const arena = new_decl_arena.getAllocator(); | |
| 4810 | const arena = new_decl_arena.allocator(); | |
| 4811 | 4811 | |
| 4812 | 4812 | // This copy accesses the old Decl Type/Value so it must be done before `clearValues`. |
| 4813 | 4813 | const new_ty = try Type.Tag.const_slice.create(arena, try tmp_test_fn_ty.copy(arena)); |
src/Sema.zig+17-17| ... | ... | @@ -418,7 +418,7 @@ pub const Block = struct { |
| 418 | 418 | finished: bool, |
| 419 | 419 | |
| 420 | 420 | pub fn arena(wad: *WipAnonDecl) Allocator { |
| 421 | return wad.new_decl_arena.getAllocator(); | |
| 421 | return wad.new_decl_arena.allocator(); | |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | pub fn deinit(wad: *WipAnonDecl) void { |
| ... | ... | @@ -1594,7 +1594,7 @@ fn zirStructDecl( |
| 1594 | 1594 | |
| 1595 | 1595 | var new_decl_arena = std.heap.ArenaAllocator.init(sema.gpa); |
| 1596 | 1596 | errdefer new_decl_arena.deinit(); |
| 1597 | const new_decl_arena_allocator = new_decl_arena.getAllocator(); | |
| 1597 | const new_decl_arena_allocator = new_decl_arena.allocator(); | |
| 1598 | 1598 | |
| 1599 | 1599 | const struct_obj = try new_decl_arena_allocator.create(Module.Struct); |
| 1600 | 1600 | const struct_ty = try Type.Tag.@"struct".create(new_decl_arena_allocator, struct_obj); |
| ... | ... | @@ -1699,7 +1699,7 @@ fn zirEnumDecl( |
| 1699 | 1699 | |
| 1700 | 1700 | var new_decl_arena = std.heap.ArenaAllocator.init(gpa); |
| 1701 | 1701 | errdefer new_decl_arena.deinit(); |
| 1702 | const new_decl_arena_allocator = new_decl_arena.getAllocator(); | |
| 1702 | const new_decl_arena_allocator = new_decl_arena.allocator(); | |
| 1703 | 1703 | |
| 1704 | 1704 | const enum_obj = try new_decl_arena_allocator.create(Module.EnumFull); |
| 1705 | 1705 | const enum_ty_payload = try new_decl_arena_allocator.create(Type.Payload.EnumFull); |
| ... | ... | @@ -1889,7 +1889,7 @@ fn zirUnionDecl( |
| 1889 | 1889 | |
| 1890 | 1890 | var new_decl_arena = std.heap.ArenaAllocator.init(sema.gpa); |
| 1891 | 1891 | errdefer new_decl_arena.deinit(); |
| 1892 | const new_decl_arena_allocator = new_decl_arena.getAllocator(); | |
| 1892 | const new_decl_arena_allocator = new_decl_arena.allocator(); | |
| 1893 | 1893 | |
| 1894 | 1894 | const union_obj = try new_decl_arena_allocator.create(Module.Union); |
| 1895 | 1895 | const type_tag: Type.Tag = if (small.has_tag_type or small.auto_enum_tag) .union_tagged else .@"union"; |
| ... | ... | @@ -1958,7 +1958,7 @@ fn zirOpaqueDecl( |
| 1958 | 1958 | |
| 1959 | 1959 | var new_decl_arena = std.heap.ArenaAllocator.init(gpa); |
| 1960 | 1960 | errdefer new_decl_arena.deinit(); |
| 1961 | const new_decl_arena_allocator = new_decl_arena.getAllocator(); | |
| 1961 | const new_decl_arena_allocator = new_decl_arena.allocator(); | |
| 1962 | 1962 | |
| 1963 | 1963 | const opaque_obj = try new_decl_arena_allocator.create(Module.Opaque); |
| 1964 | 1964 | const opaque_ty_payload = try new_decl_arena_allocator.create(Type.Payload.Opaque); |
| ... | ... | @@ -2012,7 +2012,7 @@ fn zirErrorSetDecl( |
| 2012 | 2012 | |
| 2013 | 2013 | var new_decl_arena = std.heap.ArenaAllocator.init(gpa); |
| 2014 | 2014 | errdefer new_decl_arena.deinit(); |
| 2015 | const new_decl_arena_allocator = new_decl_arena.getAllocator(); | |
| 2015 | const new_decl_arena_allocator = new_decl_arena.allocator(); | |
| 2016 | 2016 | |
| 2017 | 2017 | const error_set = try new_decl_arena_allocator.create(Module.ErrorSet); |
| 2018 | 2018 | const error_set_ty = try Type.Tag.error_set.create(new_decl_arena_allocator, error_set); |
| ... | ... | @@ -3940,7 +3940,7 @@ fn analyzeCall( |
| 3940 | 3940 | { |
| 3941 | 3941 | var arena_allocator = std.heap.ArenaAllocator.init(gpa); |
| 3942 | 3942 | errdefer arena_allocator.deinit(); |
| 3943 | const arena = arena_allocator.getAllocator(); | |
| 3943 | const arena = arena_allocator.allocator(); | |
| 3944 | 3944 | |
| 3945 | 3945 | for (memoized_call_key.args) |*arg| { |
| 3946 | 3946 | arg.* = try arg.*.copy(arena); |
| ... | ... | @@ -4074,7 +4074,7 @@ fn analyzeCall( |
| 4074 | 4074 | |
| 4075 | 4075 | var new_decl_arena = std.heap.ArenaAllocator.init(sema.gpa); |
| 4076 | 4076 | errdefer new_decl_arena.deinit(); |
| 4077 | const new_decl_arena_allocator = new_decl_arena.getAllocator(); | |
| 4077 | const new_decl_arena_allocator = new_decl_arena.allocator(); | |
| 4078 | 4078 | |
| 4079 | 4079 | // Re-run the block that creates the function, with the comptime parameters |
| 4080 | 4080 | // pre-populated inside `inst_map`. This causes `param_comptime` and |
| ... | ... | @@ -6053,8 +6053,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 6053 | 6053 | defer arena.deinit(); |
| 6054 | 6054 | |
| 6055 | 6055 | const target = sema.mod.getTarget(); |
| 6056 | const min_int = try operand_ty.minInt(arena.getAllocator(), target); | |
| 6057 | const max_int = try operand_ty.maxInt(arena.getAllocator(), target); | |
| 6056 | const min_int = try operand_ty.minInt(arena.allocator(), target); | |
| 6057 | const max_int = try operand_ty.maxInt(arena.allocator(), target); | |
| 6058 | 6058 | if (try range_set.spans(min_int, max_int, operand_ty)) { |
| 6059 | 6059 | if (special_prong == .@"else") { |
| 6060 | 6060 | return sema.fail( |
| ... | ... | @@ -12801,7 +12801,7 @@ const ComptimePtrMutationKit = struct { |
| 12801 | 12801 | |
| 12802 | 12802 | fn beginArena(self: *ComptimePtrMutationKit, gpa: Allocator) Allocator { |
| 12803 | 12803 | self.decl_arena = self.decl_ref_mut.decl.value_arena.?.promote(gpa); |
| 12804 | return self.decl_arena.getAllocator(); | |
| 12804 | return self.decl_arena.allocator(); | |
| 12805 | 12805 | } |
| 12806 | 12806 | |
| 12807 | 12807 | fn finishArena(self: *ComptimePtrMutationKit) void { |
| ... | ... | @@ -14293,7 +14293,7 @@ fn semaStructFields( |
| 14293 | 14293 | |
| 14294 | 14294 | var decl_arena = decl.value_arena.?.promote(gpa); |
| 14295 | 14295 | defer decl.value_arena.?.* = decl_arena.state; |
| 14296 | const decl_arena_allocator = decl_arena.getAllocator(); | |
| 14296 | const decl_arena_allocator = decl_arena.allocator(); | |
| 14297 | 14297 | |
| 14298 | 14298 | var analysis_arena = std.heap.ArenaAllocator.init(gpa); |
| 14299 | 14299 | defer analysis_arena.deinit(); |
| ... | ... | @@ -14301,7 +14301,7 @@ fn semaStructFields( |
| 14301 | 14301 | var sema: Sema = .{ |
| 14302 | 14302 | .mod = mod, |
| 14303 | 14303 | .gpa = gpa, |
| 14304 | .arena = analysis_arena.getAllocator(), | |
| 14304 | .arena = analysis_arena.allocator(), | |
| 14305 | 14305 | .perm_arena = decl_arena_allocator, |
| 14306 | 14306 | .code = zir, |
| 14307 | 14307 | .owner_decl = decl, |
| ... | ... | @@ -14461,7 +14461,7 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void { |
| 14461 | 14461 | |
| 14462 | 14462 | var decl_arena = union_obj.owner_decl.value_arena.?.promote(gpa); |
| 14463 | 14463 | defer union_obj.owner_decl.value_arena.?.* = decl_arena.state; |
| 14464 | const decl_arena_allocator = decl_arena.getAllocator(); | |
| 14464 | const decl_arena_allocator = decl_arena.allocator(); | |
| 14465 | 14465 | |
| 14466 | 14466 | var analysis_arena = std.heap.ArenaAllocator.init(gpa); |
| 14467 | 14467 | defer analysis_arena.deinit(); |
| ... | ... | @@ -14469,7 +14469,7 @@ fn semaUnionFields(mod: *Module, union_obj: *Module.Union) CompileError!void { |
| 14469 | 14469 | var sema: Sema = .{ |
| 14470 | 14470 | .mod = mod, |
| 14471 | 14471 | .gpa = gpa, |
| 14472 | .arena = analysis_arena.getAllocator(), | |
| 14472 | .arena = analysis_arena.allocator(), | |
| 14473 | 14473 | .perm_arena = decl_arena_allocator, |
| 14474 | 14474 | .code = zir, |
| 14475 | 14475 | .owner_decl = decl, |
| ... | ... | @@ -14623,7 +14623,7 @@ fn generateUnionTagTypeNumbered( |
| 14623 | 14623 | |
| 14624 | 14624 | var new_decl_arena = std.heap.ArenaAllocator.init(sema.gpa); |
| 14625 | 14625 | errdefer new_decl_arena.deinit(); |
| 14626 | const new_decl_arena_allocator = new_decl_arena.getAllocator(); | |
| 14626 | const new_decl_arena_allocator = new_decl_arena.allocator(); | |
| 14627 | 14627 | |
| 14628 | 14628 | const enum_obj = try new_decl_arena_allocator.create(Module.EnumNumbered); |
| 14629 | 14629 | const enum_ty_payload = try new_decl_arena_allocator.create(Type.Payload.EnumNumbered); |
| ... | ... | @@ -14660,7 +14660,7 @@ fn generateUnionTagTypeSimple(sema: *Sema, block: *Block, fields_len: u32) !Type |
| 14660 | 14660 | |
| 14661 | 14661 | var new_decl_arena = std.heap.ArenaAllocator.init(sema.gpa); |
| 14662 | 14662 | errdefer new_decl_arena.deinit(); |
| 14663 | const new_decl_arena_allocator = new_decl_arena.getAllocator(); | |
| 14663 | const new_decl_arena_allocator = new_decl_arena.allocator(); | |
| 14664 | 14664 | |
| 14665 | 14665 | const enum_obj = try new_decl_arena_allocator.create(Module.EnumSimple); |
| 14666 | 14666 | const enum_ty_payload = try new_decl_arena_allocator.create(Type.Payload.EnumSimple); |
src/codegen/c.zig+1-1| ... | ... | @@ -390,7 +390,7 @@ pub const DeclGen = struct { |
| 390 | 390 | // Fall back to generic implementation. |
| 391 | 391 | var arena = std.heap.ArenaAllocator.init(dg.module.gpa); |
| 392 | 392 | defer arena.deinit(); |
| 393 | const arena_allocator = arena.getAllocator(); | |
| 393 | const arena_allocator = arena.allocator(); | |
| 394 | 394 | |
| 395 | 395 | try writer.writeAll("{"); |
| 396 | 396 | var index: usize = 0; |
src/codegen/llvm.zig+5-5| ... | ... | @@ -331,7 +331,7 @@ pub const Object = struct { |
| 331 | 331 | |
| 332 | 332 | var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa); |
| 333 | 333 | defer arena_allocator.deinit(); |
| 334 | const arena = arena_allocator.getAllocator(); | |
| 334 | const arena = arena_allocator.allocator(); | |
| 335 | 335 | |
| 336 | 336 | const mod = comp.bin_file.options.module.?; |
| 337 | 337 | const cache_dir = mod.zig_cache_artifact_directory; |
| ... | ... | @@ -779,7 +779,7 @@ pub const DeclGen = struct { |
| 779 | 779 | |
| 780 | 780 | // The Type memory is ephemeral; since we want to store a longer-lived |
| 781 | 781 | // reference, we need to copy it here. |
| 782 | gop.key_ptr.* = try t.copy(dg.object.type_map_arena.getAllocator()); | |
| 782 | gop.key_ptr.* = try t.copy(dg.object.type_map_arena.allocator()); | |
| 783 | 783 | |
| 784 | 784 | const opaque_obj = t.castTag(.@"opaque").?.data; |
| 785 | 785 | const name = try opaque_obj.getFullyQualifiedName(gpa); |
| ... | ... | @@ -837,7 +837,7 @@ pub const DeclGen = struct { |
| 837 | 837 | |
| 838 | 838 | // The Type memory is ephemeral; since we want to store a longer-lived |
| 839 | 839 | // reference, we need to copy it here. |
| 840 | gop.key_ptr.* = try t.copy(dg.object.type_map_arena.getAllocator()); | |
| 840 | gop.key_ptr.* = try t.copy(dg.object.type_map_arena.allocator()); | |
| 841 | 841 | |
| 842 | 842 | const struct_obj = t.castTag(.@"struct").?.data; |
| 843 | 843 | |
| ... | ... | @@ -871,7 +871,7 @@ pub const DeclGen = struct { |
| 871 | 871 | |
| 872 | 872 | // The Type memory is ephemeral; since we want to store a longer-lived |
| 873 | 873 | // reference, we need to copy it here. |
| 874 | gop.key_ptr.* = try t.copy(dg.object.type_map_arena.getAllocator()); | |
| 874 | gop.key_ptr.* = try t.copy(dg.object.type_map_arena.allocator()); | |
| 875 | 875 | |
| 876 | 876 | const union_obj = t.cast(Type.Payload.Union).?.data; |
| 877 | 877 | const target = dg.module.getTarget(); |
| ... | ... | @@ -2485,7 +2485,7 @@ pub const FuncGen = struct { |
| 2485 | 2485 | |
| 2486 | 2486 | var arena_allocator = std.heap.ArenaAllocator.init(self.gpa); |
| 2487 | 2487 | defer arena_allocator.deinit(); |
| 2488 | const arena = arena_allocator.getAllocator(); | |
| 2488 | const arena = arena_allocator.allocator(); | |
| 2489 | 2489 | |
| 2490 | 2490 | const llvm_params_len = args.len; |
| 2491 | 2491 | const llvm_param_types = try arena.alloc(*const llvm.Type, llvm_params_len); |
src/crash_report.zig+1-1| ... | ... | @@ -85,7 +85,7 @@ fn dumpStatusReport() !void { |
| 85 | 85 | const anal = zir_state orelse return; |
| 86 | 86 | // Note: We have the panic mutex here, so we can safely use the global crash heap. |
| 87 | 87 | var fba = std.heap.FixedBufferAllocator.init(&crash_heap); |
| 88 | const allocator = fba.getAllocator(); | |
| 88 | const allocator = fba.allocator(); | |
| 89 | 89 | |
| 90 | 90 | const stderr = io.getStdErr().writer(); |
| 91 | 91 | const block: *Sema.Block = anal.block; |
src/glibc.zig+3-3| ... | ... | @@ -65,7 +65,7 @@ pub fn loadMetaData(gpa: Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!* |
| 65 | 65 | |
| 66 | 66 | var arena_allocator = std.heap.ArenaAllocator.init(gpa); |
| 67 | 67 | errdefer arena_allocator.deinit(); |
| 68 | const arena = arena_allocator.getAllocator(); | |
| 68 | const arena = arena_allocator.allocator(); | |
| 69 | 69 | |
| 70 | 70 | var all_versions = std.ArrayListUnmanaged(std.builtin.Version){}; |
| 71 | 71 | var all_functions = std.ArrayListUnmanaged(Fn){}; |
| ... | ... | @@ -256,7 +256,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 256 | 256 | const gpa = comp.gpa; |
| 257 | 257 | var arena_allocator = std.heap.ArenaAllocator.init(gpa); |
| 258 | 258 | defer arena_allocator.deinit(); |
| 259 | const arena = arena_allocator.getAllocator(); | |
| 259 | const arena = arena_allocator.allocator(); | |
| 260 | 260 | |
| 261 | 261 | switch (crt_file) { |
| 262 | 262 | .crti_o => { |
| ... | ... | @@ -711,7 +711,7 @@ pub fn buildSharedObjects(comp: *Compilation) !void { |
| 711 | 711 | |
| 712 | 712 | var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa); |
| 713 | 713 | defer arena_allocator.deinit(); |
| 714 | const arena = arena_allocator.getAllocator(); | |
| 714 | const arena = arena_allocator.allocator(); | |
| 715 | 715 | |
| 716 | 716 | const target = comp.getTarget(); |
| 717 | 717 | const target_version = target.os.version_range.linux.glibc; |
src/libcxx.zig+2-2| ... | ... | @@ -89,7 +89,7 @@ pub fn buildLibCXX(comp: *Compilation) !void { |
| 89 | 89 | |
| 90 | 90 | var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa); |
| 91 | 91 | defer arena_allocator.deinit(); |
| 92 | const arena = arena_allocator.getAllocator(); | |
| 92 | const arena = arena_allocator.allocator(); | |
| 93 | 93 | |
| 94 | 94 | const root_name = "c++"; |
| 95 | 95 | const output_mode = .Lib; |
| ... | ... | @@ -236,7 +236,7 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { |
| 236 | 236 | |
| 237 | 237 | var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa); |
| 238 | 238 | defer arena_allocator.deinit(); |
| 239 | const arena = arena_allocator.getAllocator(); | |
| 239 | const arena = arena_allocator.allocator(); | |
| 240 | 240 | |
| 241 | 241 | const root_name = "c++abi"; |
| 242 | 242 | const output_mode = .Lib; |
src/libtsan.zig+1-1| ... | ... | @@ -15,7 +15,7 @@ pub fn buildTsan(comp: *Compilation) !void { |
| 15 | 15 | |
| 16 | 16 | var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa); |
| 17 | 17 | defer arena_allocator.deinit(); |
| 18 | const arena = arena_allocator.getAllocator(); | |
| 18 | const arena = arena_allocator.allocator(); | |
| 19 | 19 | |
| 20 | 20 | const root_name = "tsan"; |
| 21 | 21 | const output_mode = .Lib; |
src/libunwind.zig+1-1| ... | ... | @@ -17,7 +17,7 @@ pub fn buildStaticLib(comp: *Compilation) !void { |
| 17 | 17 | |
| 18 | 18 | var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa); |
| 19 | 19 | defer arena_allocator.deinit(); |
| 20 | const arena = arena_allocator.getAllocator(); | |
| 20 | const arena = arena_allocator.allocator(); | |
| 21 | 21 | |
| 22 | 22 | const root_name = "unwind"; |
| 23 | 23 | const output_mode = .Lib; |
src/link.zig+1-1| ... | ... | @@ -628,7 +628,7 @@ pub const File = struct { |
| 628 | 628 | |
| 629 | 629 | var arena_allocator = std.heap.ArenaAllocator.init(base.allocator); |
| 630 | 630 | defer arena_allocator.deinit(); |
| 631 | const arena = arena_allocator.getAllocator(); | |
| 631 | const arena = arena_allocator.allocator(); | |
| 632 | 632 | |
| 633 | 633 | const directory = base.options.emit.?.directory; // Just an alias to make it shorter to type. |
| 634 | 634 |
src/link/C.zig+2-2| ... | ... | @@ -128,7 +128,7 @@ pub fn updateFunc(self: *C, module: *Module, func: *Module.Fn, air: Air, livenes |
| 128 | 128 | .decl = decl, |
| 129 | 129 | .fwd_decl = fwd_decl.toManaged(module.gpa), |
| 130 | 130 | .typedefs = typedefs.promote(module.gpa), |
| 131 | .typedefs_arena = self.arena.getAllocator(), | |
| 131 | .typedefs_arena = self.arena.allocator(), | |
| 132 | 132 | }, |
| 133 | 133 | .code = code.toManaged(module.gpa), |
| 134 | 134 | .indent_writer = undefined, // set later so we can get a pointer to object.code |
| ... | ... | @@ -193,7 +193,7 @@ pub fn updateDecl(self: *C, module: *Module, decl: *Module.Decl) !void { |
| 193 | 193 | .decl = decl, |
| 194 | 194 | .fwd_decl = fwd_decl.toManaged(module.gpa), |
| 195 | 195 | .typedefs = typedefs.promote(module.gpa), |
| 196 | .typedefs_arena = self.arena.getAllocator(), | |
| 196 | .typedefs_arena = self.arena.allocator(), | |
| 197 | 197 | }, |
| 198 | 198 | .code = code.toManaged(module.gpa), |
| 199 | 199 | .indent_writer = undefined, // set later so we can get a pointer to object.code |
src/link/Coff.zig+1-1| ... | ... | @@ -877,7 +877,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { |
| 877 | 877 | |
| 878 | 878 | var arena_allocator = std.heap.ArenaAllocator.init(self.base.allocator); |
| 879 | 879 | defer arena_allocator.deinit(); |
| 880 | const arena = arena_allocator.getAllocator(); | |
| 880 | const arena = arena_allocator.allocator(); | |
| 881 | 881 | |
| 882 | 882 | const directory = self.base.options.emit.?.directory; // Just an alias to make it shorter to type. |
| 883 | 883 |
src/link/Elf.zig+1-1| ... | ... | @@ -1243,7 +1243,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { |
| 1243 | 1243 | |
| 1244 | 1244 | var arena_allocator = std.heap.ArenaAllocator.init(self.base.allocator); |
| 1245 | 1245 | defer arena_allocator.deinit(); |
| 1246 | const arena = arena_allocator.getAllocator(); | |
| 1246 | const arena = arena_allocator.allocator(); | |
| 1247 | 1247 | |
| 1248 | 1248 | const directory = self.base.options.emit.?.directory; // Just an alias to make it shorter to type. |
| 1249 | 1249 |
src/link/MachO.zig+2-2| ... | ... | @@ -412,7 +412,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { |
| 412 | 412 | |
| 413 | 413 | var arena_allocator = std.heap.ArenaAllocator.init(self.base.allocator); |
| 414 | 414 | defer arena_allocator.deinit(); |
| 415 | const arena = arena_allocator.getAllocator(); | |
| 415 | const arena = arena_allocator.allocator(); | |
| 416 | 416 | |
| 417 | 417 | const directory = self.base.options.emit.?.directory; // Just an alias to make it shorter to type. |
| 418 | 418 | |
| ... | ... | @@ -5379,7 +5379,7 @@ fn snapshotState(self: *MachO) !void { |
| 5379 | 5379 | |
| 5380 | 5380 | var arena_allocator = std.heap.ArenaAllocator.init(self.base.allocator); |
| 5381 | 5381 | defer arena_allocator.deinit(); |
| 5382 | const arena = arena_allocator.getAllocator(); | |
| 5382 | const arena = arena_allocator.allocator(); | |
| 5383 | 5383 | |
| 5384 | 5384 | const out_file = try emit.directory.handle.createFile("snapshots.json", .{ |
| 5385 | 5385 | .truncate = self.cold_start, |
src/link/Plan9.zig+1-1| ... | ... | @@ -168,7 +168,7 @@ fn putFn(self: *Plan9, decl: *Module.Decl, out: FnDeclOutput) !void { |
| 168 | 168 | try fn_map_res.value_ptr.functions.put(gpa, decl, out); |
| 169 | 169 | } else { |
| 170 | 170 | const file = decl.getFileScope(); |
| 171 | const arena = self.path_arena.getAllocator(); | |
| 171 | const arena = self.path_arena.allocator(); | |
| 172 | 172 | // each file gets a symbol |
| 173 | 173 | fn_map_res.value_ptr.* = .{ |
| 174 | 174 | .sym_index = blk: { |
src/link/Wasm.zig+1-1| ... | ... | @@ -950,7 +950,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 950 | 950 | |
| 951 | 951 | var arena_allocator = std.heap.ArenaAllocator.init(self.base.allocator); |
| 952 | 952 | defer arena_allocator.deinit(); |
| 953 | const arena = arena_allocator.getAllocator(); | |
| 953 | const arena = arena_allocator.allocator(); | |
| 954 | 954 | |
| 955 | 955 | const directory = self.base.options.emit.?.directory; // Just an alias to make it shorter to type. |
| 956 | 956 |
src/link/tapi.zig+3-3| ... | ... | @@ -120,7 +120,7 @@ pub const LibStub = struct { |
| 120 | 120 | err: { |
| 121 | 121 | log.debug("trying to parse as []TbdV4", .{}); |
| 122 | 122 | const inner = lib_stub.yaml.parse([]TbdV4) catch break :err; |
| 123 | var out = try lib_stub.yaml.arena.getAllocator().alloc(Tbd, inner.len); | |
| 123 | var out = try lib_stub.yaml.arena.allocator().alloc(Tbd, inner.len); | |
| 124 | 124 | for (inner) |doc, i| { |
| 125 | 125 | out[i] = .{ .v4 = doc }; |
| 126 | 126 | } |
| ... | ... | @@ -130,7 +130,7 @@ pub const LibStub = struct { |
| 130 | 130 | err: { |
| 131 | 131 | log.debug("trying to parse as TbdV4", .{}); |
| 132 | 132 | const inner = lib_stub.yaml.parse(TbdV4) catch break :err; |
| 133 | var out = try lib_stub.yaml.arena.getAllocator().alloc(Tbd, 1); | |
| 133 | var out = try lib_stub.yaml.arena.allocator().alloc(Tbd, 1); | |
| 134 | 134 | out[0] = .{ .v4 = inner }; |
| 135 | 135 | break :blk out; |
| 136 | 136 | } |
| ... | ... | @@ -148,7 +148,7 @@ pub const LibStub = struct { |
| 148 | 148 | err: { |
| 149 | 149 | log.debug("trying to parse as TbdV3", .{}); |
| 150 | 150 | const inner = lib_stub.yaml.parse(TbdV3) catch break :err; |
| 151 | var out = try lib_stub.yaml.arena.getAllocator().alloc(Tbd, 1); | |
| 151 | var out = try lib_stub.yaml.arena.allocator().alloc(Tbd, 1); | |
| 152 | 152 | out[0] = .{ .v3 = inner }; |
| 153 | 153 | break :blk out; |
| 154 | 154 | } |
src/link/tapi/yaml.zig+4-4| ... | ... | @@ -248,7 +248,7 @@ pub const Yaml = struct { |
| 248 | 248 | |
| 249 | 249 | pub fn load(allocator: Allocator, source: []const u8) !Yaml { |
| 250 | 250 | var arena = ArenaAllocator.init(allocator); |
| 251 | const arena_allocator = arena.getAllocator(); | |
| 251 | const arena_allocator = arena.allocator(); | |
| 252 | 252 | |
| 253 | 253 | var tree = Tree.init(arena_allocator); |
| 254 | 254 | try tree.parse(source); |
| ... | ... | @@ -300,7 +300,7 @@ pub const Yaml = struct { |
| 300 | 300 | .Pointer => |info| { |
| 301 | 301 | switch (info.size) { |
| 302 | 302 | .Slice => { |
| 303 | var parsed = try self.arena.getAllocator().alloc(info.child, self.docs.items.len); | |
| 303 | var parsed = try self.arena.allocator().alloc(info.child, self.docs.items.len); | |
| 304 | 304 | for (self.docs.items) |doc, i| { |
| 305 | 305 | parsed[i] = try self.parseValue(info.child, doc); |
| 306 | 306 | } |
| ... | ... | @@ -362,7 +362,7 @@ pub const Yaml = struct { |
| 362 | 362 | |
| 363 | 363 | inline for (struct_info.fields) |field| { |
| 364 | 364 | const value: ?Value = map.get(field.name) orelse blk: { |
| 365 | const field_name = try mem.replaceOwned(u8, self.arena.getAllocator(), field.name, "_", "-"); | |
| 365 | const field_name = try mem.replaceOwned(u8, self.arena.allocator(), field.name, "_", "-"); | |
| 366 | 366 | break :blk map.get(field_name); |
| 367 | 367 | }; |
| 368 | 368 | |
| ... | ... | @@ -383,7 +383,7 @@ pub const Yaml = struct { |
| 383 | 383 | |
| 384 | 384 | fn parsePointer(self: *Yaml, comptime T: type, value: Value) Error!T { |
| 385 | 385 | const ptr_info = @typeInfo(T).Pointer; |
| 386 | const arena = self.arena.getAllocator(); | |
| 386 | const arena = self.arena.allocator(); | |
| 387 | 387 | |
| 388 | 388 | switch (ptr_info.size) { |
| 389 | 389 | .Slice => { |
src/main.zig+4-4| ... | ... | @@ -139,7 +139,7 @@ pub fn main() anyerror!void { |
| 139 | 139 | const gpa = gpa: { |
| 140 | 140 | if (!builtin.link_libc) { |
| 141 | 141 | gpa_need_deinit = true; |
| 142 | break :gpa general_purpose_allocator.getAllocator(); | |
| 142 | break :gpa general_purpose_allocator.allocator(); | |
| 143 | 143 | } |
| 144 | 144 | // We would prefer to use raw libc allocator here, but cannot |
| 145 | 145 | // use it if it won't support the alignment we need. |
| ... | ... | @@ -153,7 +153,7 @@ pub fn main() anyerror!void { |
| 153 | 153 | }; |
| 154 | 154 | var arena_instance = std.heap.ArenaAllocator.init(gpa); |
| 155 | 155 | defer arena_instance.deinit(); |
| 156 | const arena = arena_instance.getAllocator(); | |
| 156 | const arena = arena_instance.allocator(); | |
| 157 | 157 | |
| 158 | 158 | const args = try process.argsAlloc(arena); |
| 159 | 159 | |
| ... | ... | @@ -3619,7 +3619,7 @@ pub fn cmdFmt(gpa: Allocator, arena: Allocator, args: []const []const u8) !void |
| 3619 | 3619 | var errors = std.ArrayList(Compilation.AllErrors.Message).init(gpa); |
| 3620 | 3620 | defer errors.deinit(); |
| 3621 | 3621 | |
| 3622 | try Compilation.AllErrors.addZir(arena_instance.getAllocator(), &errors, &file); | |
| 3622 | try Compilation.AllErrors.addZir(arena_instance.allocator(), &errors, &file); | |
| 3623 | 3623 | const ttyconf: std.debug.TTY.Config = switch (color) { |
| 3624 | 3624 | .auto => std.debug.detectTTYConfig(), |
| 3625 | 3625 | .on => .escape_codes, |
| ... | ... | @@ -3818,7 +3818,7 @@ fn fmtPathFile( |
| 3818 | 3818 | var errors = std.ArrayList(Compilation.AllErrors.Message).init(fmt.gpa); |
| 3819 | 3819 | defer errors.deinit(); |
| 3820 | 3820 | |
| 3821 | try Compilation.AllErrors.addZir(arena_instance.getAllocator(), &errors, &file); | |
| 3821 | try Compilation.AllErrors.addZir(arena_instance.allocator(), &errors, &file); | |
| 3822 | 3822 | const ttyconf: std.debug.TTY.Config = switch (fmt.color) { |
| 3823 | 3823 | .auto => std.debug.detectTTYConfig(), |
| 3824 | 3824 | .on => .escape_codes, |
src/mingw.zig+2-2| ... | ... | @@ -25,7 +25,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 25 | 25 | } |
| 26 | 26 | var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa); |
| 27 | 27 | defer arena_allocator.deinit(); |
| 28 | const arena = arena_allocator.getAllocator(); | |
| 28 | const arena = arena_allocator.allocator(); | |
| 29 | 29 | |
| 30 | 30 | switch (crt_file) { |
| 31 | 31 | .crt2_o => { |
| ... | ... | @@ -281,7 +281,7 @@ fn add_cc_args( |
| 281 | 281 | pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { |
| 282 | 282 | var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa); |
| 283 | 283 | defer arena_allocator.deinit(); |
| 284 | const arena = arena_allocator.getAllocator(); | |
| 284 | const arena = arena_allocator.allocator(); | |
| 285 | 285 | |
| 286 | 286 | const def_file_path = findDef(comp, arena, lib_name) catch |err| switch (err) { |
| 287 | 287 | error.FileNotFound => { |
src/musl.zig+1-1| ... | ... | @@ -25,7 +25,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 25 | 25 | const gpa = comp.gpa; |
| 26 | 26 | var arena_allocator = std.heap.ArenaAllocator.init(gpa); |
| 27 | 27 | defer arena_allocator.deinit(); |
| 28 | const arena = arena_allocator.getAllocator(); | |
| 28 | const arena = arena_allocator.allocator(); | |
| 29 | 29 | |
| 30 | 30 | switch (crt_file) { |
| 31 | 31 | .crti_o => { |
src/print_air.zig+1-1| ... | ... | @@ -47,7 +47,7 @@ pub fn dump(gpa: Allocator, air: Air, zir: Zir, liveness: Liveness) void { |
| 47 | 47 | |
| 48 | 48 | var writer: Writer = .{ |
| 49 | 49 | .gpa = gpa, |
| 50 | .arena = arena.getAllocator(), | |
| 50 | .arena = arena.allocator(), | |
| 51 | 51 | .air = air, |
| 52 | 52 | .zir = zir, |
| 53 | 53 | .liveness = liveness, |
src/print_zir.zig+3-3| ... | ... | @@ -19,7 +19,7 @@ pub fn renderAsTextToFile( |
| 19 | 19 | |
| 20 | 20 | var writer: Writer = .{ |
| 21 | 21 | .gpa = gpa, |
| 22 | .arena = arena.getAllocator(), | |
| 22 | .arena = arena.allocator(), | |
| 23 | 23 | .file = scope_file, |
| 24 | 24 | .code = scope_file.zir, |
| 25 | 25 | .indent = 0, |
| ... | ... | @@ -74,7 +74,7 @@ pub fn renderInstructionContext( |
| 74 | 74 | |
| 75 | 75 | var writer: Writer = .{ |
| 76 | 76 | .gpa = gpa, |
| 77 | .arena = arena.getAllocator(), | |
| 77 | .arena = arena.allocator(), | |
| 78 | 78 | .file = scope_file, |
| 79 | 79 | .code = scope_file.zir, |
| 80 | 80 | .indent = if (indent < 2) 2 else indent, |
| ... | ... | @@ -106,7 +106,7 @@ pub fn renderSingleInstruction( |
| 106 | 106 | |
| 107 | 107 | var writer: Writer = .{ |
| 108 | 108 | .gpa = gpa, |
| 109 | .arena = arena.getAllocator(), | |
| 109 | .arena = arena.allocator(), | |
| 110 | 110 | .file = scope_file, |
| 111 | 111 | .code = scope_file.zir, |
| 112 | 112 | .indent = indent, |
src/stage1.zig+1-1| ... | ... | @@ -38,7 +38,7 @@ pub fn main(argc: c_int, argv: [*][*:0]u8) callconv(.C) c_int { |
| 38 | 38 | const gpa = std.heap.c_allocator; |
| 39 | 39 | var arena_instance = std.heap.ArenaAllocator.init(gpa); |
| 40 | 40 | defer arena_instance.deinit(); |
| 41 | const arena = arena_instance.getAllocator(); | |
| 41 | const arena = arena_instance.allocator(); | |
| 42 | 42 | |
| 43 | 43 | const args = arena.alloc([]const u8, @intCast(usize, argc)) catch fatal("{s}", .{"OutOfMemory"}); |
| 44 | 44 | for (args) |*arg, i| { |
src/test.zig+1-1| ... | ... | @@ -692,7 +692,7 @@ pub const TestContext = struct { |
| 692 | 692 | |
| 693 | 693 | var arena_allocator = std.heap.ArenaAllocator.init(allocator); |
| 694 | 694 | defer arena_allocator.deinit(); |
| 695 | const arena = arena_allocator.getAllocator(); | |
| 695 | const arena = arena_allocator.allocator(); | |
| 696 | 696 | |
| 697 | 697 | var tmp = std.testing.tmpDir(.{}); |
| 698 | 698 | defer tmp.cleanup(); |
src/translate_c.zig+1-1| ... | ... | @@ -373,7 +373,7 @@ pub fn translate( |
| 373 | 373 | // from this function. |
| 374 | 374 | var arena = std.heap.ArenaAllocator.init(gpa); |
| 375 | 375 | errdefer arena.deinit(); |
| 376 | const arena_allocator = arena.getAllocator(); | |
| 376 | const arena_allocator = arena.allocator(); | |
| 377 | 377 | |
| 378 | 378 | var context = Context{ |
| 379 | 379 | .gpa = gpa, |
src/wasi_libc.zig+1-1| ... | ... | @@ -67,7 +67,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 67 | 67 | const gpa = comp.gpa; |
| 68 | 68 | var arena_allocator = std.heap.ArenaAllocator.init(gpa); |
| 69 | 69 | defer arena_allocator.deinit(); |
| 70 | const arena = arena_allocator.getAllocator(); | |
| 70 | const arena = arena_allocator.allocator(); | |
| 71 | 71 | |
| 72 | 72 | switch (crt_file) { |
| 73 | 73 | .crt1_reactor_o => { |
test/cli.zig+1-1| ... | ... | @@ -16,7 +16,7 @@ pub fn main() !void { |
| 16 | 16 | // skip my own exe name |
| 17 | 17 | _ = arg_it.skip(); |
| 18 | 18 | |
| 19 | a = arena.getAllocator(); | |
| 19 | a = arena.allocator(); | |
| 20 | 20 | |
| 21 | 21 | const zig_exe_rel = try (arg_it.next(a) orelse { |
| 22 | 22 | std.debug.print("Expected first argument to be path to zig compiler\n", .{}); |
test/compare_output.zig+1-1| ... | ... | @@ -491,7 +491,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 491 | 491 | \\pub fn main() !void { |
| 492 | 492 | \\ var allocator_buf: [10]u8 = undefined; |
| 493 | 493 | \\ var fixedBufferAllocator = std.mem.validationWrap(std.heap.FixedBufferAllocator.init(&allocator_buf)); |
| 494 | \\ const allocator = std.heap.loggingAllocator(fixedBufferAllocator.getAllocator()).getAllocator(); | |
| 494 | \\ const allocator = std.heap.loggingAllocator(fixedBufferAllocator.allocator()).allocator(); | |
| 495 | 495 | \\ |
| 496 | 496 | \\ var a = try allocator.alloc(u8, 10); |
| 497 | 497 | \\ a = allocator.shrink(a, 5); |
test/standalone/brace_expansion/main.zig+1-1| ... | ... | @@ -16,7 +16,7 @@ const Token = union(enum) { |
| 16 | 16 | }; |
| 17 | 17 | |
| 18 | 18 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; |
| 19 | const global_allocator = gpa.getAllocator(); | |
| 19 | const global_allocator = gpa.allocator(); | |
| 20 | 20 | |
| 21 | 21 | fn tokenize(input: []const u8) !ArrayList(Token) { |
| 22 | 22 | const State = enum { |
test/standalone/cat/main.zig+1-1| ... | ... | @@ -8,7 +8,7 @@ const warn = std.log.warn; |
| 8 | 8 | pub fn main() !void { |
| 9 | 9 | var arena_instance = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 10 | 10 | defer arena_instance.deinit(); |
| 11 | const arena = arena_instance.getAllocator(); | |
| 11 | const arena = arena_instance.allocator(); | |
| 12 | 12 | |
| 13 | 13 | const args = try process.argsAlloc(arena); |
| 14 | 14 |
tools/gen_spirv_spec.zig+1-1| ... | ... | @@ -4,7 +4,7 @@ const g = @import("spirv/grammar.zig"); |
| 4 | 4 | pub fn main() !void { |
| 5 | 5 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 6 | 6 | defer arena.deinit(); |
| 7 | const allocator = arena.getAllocator(); | |
| 7 | const allocator = arena.allocator(); | |
| 8 | 8 | |
| 9 | 9 | const args = try std.process.argsAlloc(allocator); |
| 10 | 10 | if (args.len != 2) { |
tools/gen_stubs.zig+1-1| ... | ... | @@ -25,7 +25,7 @@ pub fn main() !void { |
| 25 | 25 | |
| 26 | 26 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 27 | 27 | defer arena.deinit(); |
| 28 | const ally = arena.getAllocator(); | |
| 28 | const ally = arena.allocator(); | |
| 29 | 29 | |
| 30 | 30 | var symbols = std.ArrayList(Symbol).init(ally); |
| 31 | 31 | var sections = std.ArrayList([]const u8).init(ally); |
tools/merge_anal_dumps.zig+1-1| ... | ... | @@ -9,7 +9,7 @@ pub fn main() anyerror!void { |
| 9 | 9 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 10 | 10 | defer arena.deinit(); |
| 11 | 11 | |
| 12 | const allocator = arena.getAllocator(); | |
| 12 | const allocator = arena.allocator(); | |
| 13 | 13 | |
| 14 | 14 | const args = try std.process.argsAlloc(allocator); |
| 15 | 15 |
tools/process_headers.zig+1-1| ... | ... | @@ -284,7 +284,7 @@ const LibCVendor = enum { |
| 284 | 284 | |
| 285 | 285 | pub fn main() !void { |
| 286 | 286 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 287 | const allocator = arena.getAllocator(); | |
| 287 | const allocator = arena.allocator(); | |
| 288 | 288 | const args = try std.process.argsAlloc(allocator); |
| 289 | 289 | var search_paths = std.ArrayList([]const u8).init(allocator); |
| 290 | 290 | var opt_out_dir: ?[]const u8 = null; |
tools/update-license-headers.zig+1-1| ... | ... | @@ -10,7 +10,7 @@ pub fn main() !void { |
| 10 | 10 | defer root_node.end(); |
| 11 | 11 | |
| 12 | 12 | var arena_allocator = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 13 | const arena = arena_allocator.getAllocator(); | |
| 13 | const arena = arena_allocator.allocator(); | |
| 14 | 14 | |
| 15 | 15 | const args = try std.process.argsAlloc(arena); |
| 16 | 16 | const path_to_walk = args[1]; |
tools/update_clang_options.zig+1-6| ... | ... | @@ -450,13 +450,8 @@ const cpu_targets = struct { |
| 450 | 450 | pub fn main() anyerror!void { |
| 451 | 451 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 452 | 452 | defer arena.deinit(); |
| 453 | <<<<<<< HEAD | |
| 454 | const allocator = &arena.allocator; | |
| 455 | 453 | |
| 456 | ======= | |
| 457 | ||
| 458 | const allocator = arena.getAllocator(); | |
| 459 | >>>>>>> 11157e318 (allocgate: stage 1 and 2 building) | |
| 454 | const allocator = arena.allocator(); | |
| 460 | 455 | const args = try std.process.argsAlloc(allocator); |
| 461 | 456 | |
| 462 | 457 | if (args.len <= 1) { |
tools/update_cpu_features.zig+2-2| ... | ... | @@ -769,7 +769,7 @@ const llvm_targets = [_]LlvmTarget{ |
| 769 | 769 | pub fn main() anyerror!void { |
| 770 | 770 | var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 771 | 771 | defer arena_state.deinit(); |
| 772 | const arena = arena_state.getAllocator(); | |
| 772 | const arena = arena_state.allocator(); | |
| 773 | 773 | |
| 774 | 774 | const args = try std.process.argsAlloc(arena); |
| 775 | 775 | if (args.len <= 1) { |
| ... | ... | @@ -845,7 +845,7 @@ fn processOneTarget(job: Job) anyerror!void { |
| 845 | 845 | |
| 846 | 846 | var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 847 | 847 | defer arena_state.deinit(); |
| 848 | const arena = arena_state.getAllocator(); | |
| 848 | const arena = arena_state.allocator(); | |
| 849 | 849 | |
| 850 | 850 | var progress_node = job.root_progress.start(llvm_target.zig_name, 3); |
| 851 | 851 | progress_node.activate(); |
tools/update_glibc.zig+1-1| ... | ... | @@ -133,7 +133,7 @@ const Function = struct { |
| 133 | 133 | |
| 134 | 134 | pub fn main() !void { |
| 135 | 135 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 136 | const allocator = arena.getAllocator(); | |
| 136 | const allocator = arena.allocator(); | |
| 137 | 137 | const args = try std.process.argsAlloc(allocator); |
| 138 | 138 | const in_glibc_dir = args[1]; // path to the unzipped tarball of glibc, e.g. ~/downloads/glibc-2.25 |
| 139 | 139 | const zig_src_dir = args[2]; // path to the source checkout of zig, lib dir, e.g. ~/zig-src/lib |
tools/update_spirv_features.zig+1-1| ... | ... | @@ -48,7 +48,7 @@ const Version = struct { |
| 48 | 48 | pub fn main() !void { |
| 49 | 49 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 50 | 50 | defer arena.deinit(); |
| 51 | const allocator = arena.getAllocator(); | |
| 51 | const allocator = arena.allocator(); | |
| 52 | 52 | |
| 53 | 53 | const args = try std.process.argsAlloc(allocator); |
| 54 | 54 |