glfw: fix gammaramp free allocation size
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
a937fe0a17
commit
ed2185f7e4
1 changed files with 4 additions and 4 deletions
|
@ -17,7 +17,7 @@ const GammaRamp = @This();
|
||||||
red: []u16,
|
red: []u16,
|
||||||
green: []u16,
|
green: []u16,
|
||||||
blue: []u16,
|
blue: []u16,
|
||||||
owned: bool,
|
owned: ?[]u16,
|
||||||
|
|
||||||
/// Initializes a new owned gamma ramp with the given array size and undefined values.
|
/// 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],
|
.red = buf[size * 0 .. (size * 0) + size],
|
||||||
.green = buf[size * 1 .. (size * 1) + size],
|
.green = buf[size * 1 .. (size * 1) + size],
|
||||||
.blue = buf[size * 2 .. (size * 2) + 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],
|
.red = native.red[0..native.size],
|
||||||
.green = native.green[0..native.size],
|
.green = native.green[0..native.size],
|
||||||
.blue = native.blue[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`.
|
/// Deinitializes the memory using the allocator iff `.owned = true`.
|
||||||
pub inline fn deinit(self: GammaRamp, allocator: mem.Allocator) void {
|
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" {
|
test "conversion" {
|
||||||
|
|
Loading…
Add table
Reference in a new issue