mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
fix memory leaks
This commit is contained in:
@ -51,9 +51,9 @@ pub fn init(alloc: Allocator) !Grid {
|
|||||||
// Initialize our font atlas. We will initially populate the
|
// Initialize our font atlas. We will initially populate the
|
||||||
// font atlas with all the visible ASCII characters since they are common.
|
// font atlas with all the visible ASCII characters since they are common.
|
||||||
var atlas = try Atlas.init(alloc, 512);
|
var atlas = try Atlas.init(alloc, 512);
|
||||||
errdefer atlas.deinit(alloc);
|
defer atlas.deinit(alloc);
|
||||||
var font = try FontAtlas.init(atlas);
|
var font = try FontAtlas.init(atlas);
|
||||||
errdefer font.deinit(alloc);
|
defer font.deinit(alloc);
|
||||||
try font.loadFaceFromMemory(face_ttf, 30);
|
try font.loadFaceFromMemory(face_ttf, 30);
|
||||||
|
|
||||||
// Load all visible ASCII characters and build our cell width based on
|
// Load all visible ASCII characters and build our cell width based on
|
||||||
@ -104,6 +104,11 @@ pub fn init(alloc: Allocator) !Grid {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn deinit(self: *Grid) void {
|
||||||
|
self.program.destroy();
|
||||||
|
self.* = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the screen size for rendering. This will update the projection
|
/// Set the screen size for rendering. This will update the projection
|
||||||
/// used for the shader so that the scaling of the grid is correct.
|
/// used for the shader so that the scaling of the grid is correct.
|
||||||
pub fn setScreenSize(self: *Grid, dim: ScreenDim) !void {
|
pub fn setScreenSize(self: *Grid, dim: ScreenDim) !void {
|
||||||
|
@ -77,6 +77,7 @@ pub fn create(alloc: Allocator) !*Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn destroy(self: *Window, alloc: Allocator) void {
|
pub fn destroy(self: *Window, alloc: Allocator) void {
|
||||||
|
self.grid.deinit();
|
||||||
alloc.destroy(self);
|
alloc.destroy(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,8 +103,9 @@ fn sizeCallback(window: glfw.Window, width: i32, height: i32) void {
|
|||||||
win.grid.setScreenSize(.{
|
win.grid.setScreenSize(.{
|
||||||
.width = width,
|
.width = width,
|
||||||
.height = height,
|
.height = height,
|
||||||
}) catch unreachable;
|
}) catch |err| log.err("error updating grid screen size err={}", .{err});
|
||||||
|
|
||||||
// Update our viewport for this context to be the entire window
|
// Update our viewport for this context to be the entire window
|
||||||
try gl.viewport(0, 0, width, height);
|
gl.viewport(0, 0, width, height) catch |err|
|
||||||
|
log.err("error updating OpenGL viewport err={}", .{err});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user