From 282bb8f1458ca5ab9aea1ce4908eb301982bd75d Mon Sep 17 00:00:00 2001 From: Altagos Date: Mon, 6 Jan 2025 11:31:49 +0100 Subject: [PATCH] already passing a pointer --- src/rayray.zig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/rayray.zig b/src/rayray.zig index 3a19105..ea1c37c 100644 --- a/src/rayray.zig +++ b/src/rayray.zig @@ -98,7 +98,7 @@ pub const Raytracer = struct { var create_pixels_node = root_node.start("Create pixel array", 0); - const pixels = try self.allocator.alloc(zmath.Vec, self.scene.camera.image_height * self.scene.camera.image_width); + const pixels: []zmath.Vec = try self.allocator.alloc(zmath.Vec, self.scene.camera.image_height * self.scene.camera.image_width); defer self.allocator.free(pixels); // const l = pixels.ptr; @@ -107,7 +107,7 @@ pub const Raytracer = struct { var task_node = root_node.start("Creating render tasks", 0); - const tasks = try self.allocator.alloc(TaskTracker, num_chunks); + const tasks: []TaskTracker = try self.allocator.alloc(TaskTracker, num_chunks); defer self.allocator.free(tasks); for (tasks, 0..) |*t, id| { @@ -121,8 +121,6 @@ pub const Raytracer = struct { const ctx = try self.allocator.create(tracer.Context); - // FIXME: might cause the segfault - // possible fix: pass a pointer to the context as argument (create via allocator) ctx.* = tracer.Context{ .pixels = pixels, .cam = &self.scene.camera, -- 2.51.2