@@ -49,7 +49,7 @@ extern fn meshopt_setAllocator(
4949var mem_allocator : ? std.mem.Allocator = null ;
5050var mem_allocations : ? std .AutoHashMap (usize , usize ) = null ;
5151var mem_mutex : std.Thread.Mutex = .{};
52- const mem_alignment = 16 ;
52+ const mem_alignment : std.mem.Alignment = .@"16" ;
5353
5454pub fn zmeshMalloc (size : usize ) callconv (.C ) ? * anyopaque {
5555 mem_mutex .lock ();
@@ -87,9 +87,9 @@ fn zmeshRealloc(ptr: ?*anyopaque, size: usize) callconv(.C) ?*anyopaque {
8787 const old_size = if (ptr != null ) mem_allocations .? .get (@intFromPtr (ptr .? )).? else 0 ;
8888
8989 const old_mem = if (old_size > 0 )
90- @as ([* ]align (mem_alignment ) u8 , @ptrCast (@alignCast (ptr )))[0.. old_size ]
90+ @as ([* ]align (mem_alignment . toByteUnits () ) u8 , @ptrCast (@alignCast (ptr )))[0.. old_size ]
9191 else
92- @as ([* ]align (mem_alignment ) u8 , undefined )[0.. 0];
92+ @as ([* ]align (mem_alignment . toByteUnits () ) u8 , undefined )[0.. 0];
9393
9494 const mem = mem_allocator .? .realloc (old_mem , size ) catch @panic ("zmesh: out of memory" );
9595
@@ -109,7 +109,7 @@ fn zmeshFree(maybe_ptr: ?*anyopaque) callconv(.C) void {
109109 defer mem_mutex .unlock ();
110110
111111 const size = mem_allocations .? .fetchRemove (@intFromPtr (ptr )).? .value ;
112- const mem = @as ([* ]align (mem_alignment ) u8 , @ptrCast (@alignCast (ptr )))[0.. size ];
112+ const mem = @as ([* ]align (mem_alignment . toByteUnits () ) u8 , @ptrCast (@alignCast (ptr )))[0.. size ];
113113 mem_allocator .? .free (mem );
114114 }
115115}
0 commit comments