chore: remove all memory leaks
This commit is contained in:
10
src/ppu.zig
10
src/ppu.zig
@@ -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]));
|
||||
}
|
||||
|
Reference in New Issue
Block a user