fix(emu): resolve double free with main mem ptr

This commit is contained in:
Rekai Nyangadzayi Musuka 2023-09-05 02:00:53 -05:00
parent 0c6f710822
commit cd3a3dbe63
3 changed files with 4 additions and 10 deletions

View File

@ -33,7 +33,6 @@ pub fn init(allocator: Allocator, scheduler: *Scheduler, shared_ctx: SharedConte
}
pub fn deinit(self: *@This(), allocator: Allocator) void {
allocator.destroy(self.main);
allocator.destroy(self.wram);
}

View File

@ -40,7 +40,6 @@ pub fn init(allocator: Allocator, scheduler: *Scheduler, shared_ctx: SharedConte
pub fn deinit(self: *@This(), allocator: Allocator) void {
self.ppu.deinit(allocator);
allocator.destroy(self.main);
allocator.destroy(self.vram1);
}

View File

@ -23,7 +23,7 @@ const nds_height = ppu.screen_height;
pub const Dimensions = struct { width: u32, height: u32 };
const window_title = "Turbo (Name Pending)";
const window_title = "Turbo";
pub const Ui = struct {
const Self = @This();
@ -82,8 +82,7 @@ pub const Ui = struct {
SDL.SDL_Quit();
}
fn glGetProcAddress(ctx: SDL.SDL_GLContext, proc: [:0]const u8) ?*anyopaque {
_ = ctx;
fn glGetProcAddress(_: SDL.SDL_GLContext, proc: [:0]const u8) ?*anyopaque {
return SDL.SDL_GL_GetProcAddress(proc.ptr);
}
@ -220,7 +219,7 @@ const opengl_impl = struct {
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, nds_width, nds_height, gl.RGBA, gl.UNSIGNED_INT_8_8_8_8, buf.ptr);
// Bind VAO
gl.bindVertexArray(vao_id); // VAO
gl.bindVertexArray(vao_id);
defer gl.bindVertexArray(0);
// Use compiled frag + vertex shader
@ -303,9 +302,7 @@ const opengl_impl = struct {
defer gl.bindFramebuffer(gl.FRAMEBUFFER, 0);
gl.framebufferTexture(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, tex_id, 0);
const draw_buffers: [1]GLuint = .{gl.COLOR_ATTACHMENT0};
gl.drawBuffers(1, &draw_buffers);
gl.drawBuffers(1, &@as(GLuint, gl.COLOR_ATTACHMENT0));
if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE)
return error.FrameBufferObejctInitFailed;
@ -314,7 +311,6 @@ const opengl_impl = struct {
}
const shader = struct {
const Kind = enum { vertex, fragment };
const log = std.log.scoped(.shader);
fn didCompile(id: gl.GLuint) bool {