diff --git a/libs/glfw/src/GammaRamp.zig b/libs/glfw/src/GammaRamp.zig index f13923d1..bc33d0f8 100644 --- a/libs/glfw/src/GammaRamp.zig +++ b/libs/glfw/src/GammaRamp.zig @@ -17,7 +17,7 @@ const GammaRamp = @This(); red: []u16, green: []u16, blue: []u16, -owned: bool, +owned: ?[]u16, /// Initializes a new owned gamma ramp with the given array size and undefined values. /// @@ -28,7 +28,7 @@ pub inline fn init(allocator: mem.Allocator, size: usize) !GammaRamp { .red = buf[size * 0 .. (size * 0) + size], .green = buf[size * 1 .. (size * 1) + size], .blue = buf[size * 2 .. (size * 2) + size], - .owned = true, + .owned = buf, }; } @@ -40,7 +40,7 @@ pub inline fn fromC(native: c.GLFWgammaramp) GammaRamp { .red = native.red[0..native.size], .green = native.green[0..native.size], .blue = native.blue[0..native.size], - .owned = false, + .owned = null, }; } @@ -60,7 +60,7 @@ pub inline fn toC(self: GammaRamp) c.GLFWgammaramp { /// Deinitializes the memory using the allocator iff `.owned = true`. pub inline fn deinit(self: GammaRamp, allocator: mem.Allocator) void { - if (self.owned) allocator.free(self.red); + if (self.owned) |buf| allocator.free(buf); } test "conversion" {