mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
main: fix tracy allocator in GlobalState
This commit is contained in:
10
src/main.zig
10
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 {
|
||||
|
Reference in New Issue
Block a user