diff --git a/src/Core.zig b/src/Core.zig index a3013ef1..35f6a161 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -66,6 +66,11 @@ pub fn printTitle( comptime fmt: []const u8, args: anytype, ) !void { + // Free any previous window title slice + // TODO: reuse allocations + if (core.get(window_id, .title)) |slice| core.state().allocator.free(slice); + + // Allocate and assign a new window title slice. const slice = try std.fmt.allocPrintZ(core.state().allocator, fmt, args); try core.set(window_id, .title, slice); }