From f0a508386f4ccd382df8831b7907c3f6685c2453 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Tue, 5 Sep 2023 02:00:53 -0500 Subject: [PATCH] fix(emu): resolve double free with main mem ptr --- src/core/nds7/Bus.zig | 1 - src/core/nds9/Bus.zig | 1 - src/platform.zig | 12 ++++-------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/core/nds7/Bus.zig b/src/core/nds7/Bus.zig index c474c3e..738dccf 100644 --- a/src/core/nds7/Bus.zig +++ b/src/core/nds7/Bus.zig @@ -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); } diff --git a/src/core/nds9/Bus.zig b/src/core/nds9/Bus.zig index d62e73c..803e35f 100644 --- a/src/core/nds9/Bus.zig +++ b/src/core/nds9/Bus.zig @@ -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); } diff --git a/src/platform.zig b/src/platform.zig index f80d4f2..f9f5acd 100644 --- a/src/platform.zig +++ b/src/platform.zig @@ -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 {