session: self destroy

This commit is contained in:
Pierre Tachoire
2024-01-15 17:55:21 +01:00
parent 25f290283b
commit 07be51cd1d

View File

@@ -41,7 +41,6 @@ pub const Browser = struct {
pub fn deinit(self: *Browser) void { pub fn deinit(self: *Browser) void {
self.session.deinit(); self.session.deinit();
self.alloc.destroy(self.session);
} }
pub fn currentSession(self: *Browser) *Session { pub fn currentSession(self: *Browser) *Session {
@@ -55,6 +54,7 @@ pub const Browser = struct {
// You can create successively multiple pages for a session, but you must // You can create successively multiple pages for a session, but you must
// deinit a page before running another one. // deinit a page before running another one.
pub const Session = struct { pub const Session = struct {
alloc: std.mem.Allocator,
arena: std.heap.ArenaAllocator, arena: std.heap.ArenaAllocator,
uri: []const u8, uri: []const u8,
@@ -70,6 +70,7 @@ pub const Session = struct {
var self = try alloc.create(Session); var self = try alloc.create(Session);
self.* = Session{ self.* = Session{
.uri = uri, .uri = uri,
.alloc = alloc,
.arena = std.heap.ArenaAllocator.init(alloc), .arena = std.heap.ArenaAllocator.init(alloc),
.window = Window.create(null), .window = Window.create(null),
}; };
@@ -90,6 +91,7 @@ pub const Session = struct {
self.loop.deinit(); self.loop.deinit();
self.env.deinit(); self.env.deinit();
self.arena.deinit(); self.arena.deinit();
self.alloc.destroy(self);
} }
pub fn createPage(self: *Session) !Page { pub fn createPage(self: *Session) !Page {