chore: remove all memory leaks

This commit is contained in:
2022-10-21 05:11:47 -03:00
parent 5c5179a553
commit da7300a78c
6 changed files with 37 additions and 1 deletions

View File

@@ -10,17 +10,27 @@ pub const Ppu = struct {
.vram = try Vram.init(alloc),
};
}
pub fn deinit(self: *@This()) void {
self.vram.deinit();
}
};
const Vram = struct {
buf: []u8,
alloc: Allocator,
fn init(alloc: Allocator) !@This() {
return @This(){
.buf = try alloc.alloc(u8, 0x18000),
.alloc = alloc,
};
}
fn deinit(self: *@This()) void {
self.alloc.free(self.buf);
}
pub inline fn get32(self: *const @This(), idx: usize) u32 {
return (@as(u32, self.buf[idx + 3]) << 24) | (@as(u32, self.buf[idx + 2]) << 16) | (@as(u32, self.buf[idx + 1]) << 8) | (@as(u32, self.buf[idx]));
}