diff --git a/src/main.zig b/src/main.zig index b84322af6..48c4d2a71 100644 --- a/src/main.zig +++ b/src/main.zig @@ -173,6 +173,7 @@ pub const GlobalState = struct { gpa: ?GPA, alloc: std.mem.Allocator, + tracy: if (tracy.enabled) ?tracy.Allocator(null) else void, pub fn init(self: *GlobalState) void { // Output some debug information right away @@ -194,6 +195,7 @@ pub const GlobalState = struct { self.* = .{ .gpa = null, .alloc = undefined, + .tracy = undefined, }; errdefer self.deinit(); @@ -224,8 +226,8 @@ pub const GlobalState = struct { // If we're tracing, wrap the allocator if (!tracy.enabled) break :alloc base; - var tracy_alloc = tracy.allocator(base, null); - break :alloc tracy_alloc.allocator(); + self.tracy = tracy.allocator(base, null); + break :alloc self.tracy.?.allocator(); }; } @@ -237,6 +239,10 @@ pub const GlobalState = struct { // the point at which it will output if there were safety violations. _ = value.deinit(); } + + if (tracy.enabled) { + self.tracy = null; + } } }; test {