Fix alignment in getUserData
This commit is contained in:
parent
452be0a0b8
commit
c12c0ea0fb
@ -78,7 +78,7 @@ pub fn Window(comptime TUserData: type) type {
|
||||
|
||||
pub fn getUserData(self: Window(TUserData)) ?*TUserData {
|
||||
var cData = c.mfb_get_user_data(self.cwin);
|
||||
return @ptrCast(?*TUserData, @alignCast(@alignOf(?*TUserData), cData));
|
||||
return @ptrCast(?*TUserData, @alignCast(@alignOf(TUserData), cData));
|
||||
}
|
||||
|
||||
pub const ActiveFunc = fn (win: Window(TUserData), isActive: bool) callconv(.C) void;
|
||||
@ -102,6 +102,14 @@ test "user data is not null if previously set" {
|
||||
try testing.expectEqual(expected, win.getUserData().?.*);
|
||||
}
|
||||
|
||||
test "also works with smaller user data" {
|
||||
const win = try Window(u8).open("abc", 100, 100, .{});
|
||||
var data: u8 = 42;
|
||||
win.setUserData(&data);
|
||||
const expected: u8 = 42;
|
||||
try testing.expectEqual(expected, win.getUserData().?.*);
|
||||
}
|
||||
|
||||
pub fn getTargetFPS() u32 {
|
||||
return c.mfb_get_target_fps();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user