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 cham = @import("chameleon");
|
||||
|
||||
const TrackedString = @import("../util/trackedString.zig").TrackedString;
|
||||
|
||||
const log = std.log;
|
||||
|
||||
pub const Level = log.Level;
|
||||
|
|
@ -18,10 +20,10 @@ pub const Color = enum {
|
|||
};
|
||||
|
||||
pub const ScopeModifier = struct {
|
||||
scope: []const u8,
|
||||
scope: TrackedString,
|
||||
color: ?Color = .default,
|
||||
bright: bool = false,
|
||||
rename: ?[]const u8 = null,
|
||||
rename: ?TrackedString = null,
|
||||
};
|
||||
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
|
@ -58,12 +60,12 @@ const Globals = struct {
|
|||
file.close();
|
||||
}
|
||||
|
||||
for (self.additionalScopes.items) |modifier| {
|
||||
if (modifier.rename) |value| {
|
||||
self.allocator.free(value);
|
||||
for (self.additionalScopes.items) |*modifier| {
|
||||
if (modifier.*.rename) |*value| {
|
||||
value.deinit();
|
||||
}
|
||||
|
||||
self.allocator.free(modifier.scope);
|
||||
modifier.*.scope.deinit();
|
||||
}
|
||||
self.additionalScopes.deinit();
|
||||
|
||||
|
|
|
|||
|
|
@ -18,17 +18,17 @@ pub const TrackedString = struct {
|
|||
};
|
||||
}
|
||||
|
||||
pub fn deinit(self: TrackedString) void {
|
||||
switch (self.kind) {
|
||||
pub fn deinit(self: *TrackedString) void {
|
||||
switch (self.*.kind) {
|
||||
.Constant => {
|
||||
self.value = undefined;
|
||||
self.kind = .{ .Dead = {} };
|
||||
self.*.data = undefined;
|
||||
self.*.kind = .{ .Dead = {} };
|
||||
},
|
||||
|
||||
.Allocated => |allocator| {
|
||||
allocator.free(self.value);
|
||||
self.value = undefined;
|
||||
self.kind = .{ .Dead = {} };
|
||||
allocator.free(self.data);
|
||||
self.*.data = undefined;
|
||||
self.*.kind = .{ .Dead = {} };
|
||||
},
|
||||
|
||||
.Dead => {},
|
||||
|
|
|
|||
Loading…
Reference in a new issue