Put TrackedString to use
This commit is contained in:
parent
519c09aef6
commit
580b12b111
2 changed files with 15 additions and 13 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const cham = @import("chameleon");
|
const cham = @import("chameleon");
|
||||||
|
|
||||||
|
const TrackedString = @import("../util/trackedString.zig").TrackedString;
|
||||||
|
|
||||||
const log = std.log;
|
const log = std.log;
|
||||||
|
|
||||||
pub const Level = log.Level;
|
pub const Level = log.Level;
|
||||||
|
|
@ -18,10 +20,10 @@ pub const Color = enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ScopeModifier = struct {
|
pub const ScopeModifier = struct {
|
||||||
scope: []const u8,
|
scope: TrackedString,
|
||||||
color: ?Color = .default,
|
color: ?Color = .default,
|
||||||
bright: bool = false,
|
bright: bool = false,
|
||||||
rename: ?[]const u8 = null,
|
rename: ?TrackedString = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
|
|
@ -58,12 +60,12 @@ const Globals = struct {
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (self.additionalScopes.items) |modifier| {
|
for (self.additionalScopes.items) |*modifier| {
|
||||||
if (modifier.rename) |value| {
|
if (modifier.*.rename) |*value| {
|
||||||
self.allocator.free(value);
|
value.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.allocator.free(modifier.scope);
|
modifier.*.scope.deinit();
|
||||||
}
|
}
|
||||||
self.additionalScopes.deinit();
|
self.additionalScopes.deinit();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,17 +18,17 @@ pub const TrackedString = struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: TrackedString) void {
|
pub fn deinit(self: *TrackedString) void {
|
||||||
switch (self.kind) {
|
switch (self.*.kind) {
|
||||||
.Constant => {
|
.Constant => {
|
||||||
self.value = undefined;
|
self.*.data = undefined;
|
||||||
self.kind = .{ .Dead = {} };
|
self.*.kind = .{ .Dead = {} };
|
||||||
},
|
},
|
||||||
|
|
||||||
.Allocated => |allocator| {
|
.Allocated => |allocator| {
|
||||||
allocator.free(self.value);
|
allocator.free(self.data);
|
||||||
self.value = undefined;
|
self.*.data = undefined;
|
||||||
self.kind = .{ .Dead = {} };
|
self.*.kind = .{ .Dead = {} };
|
||||||
},
|
},
|
||||||
|
|
||||||
.Dead => {},
|
.Dead => {},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue