Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .zigversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14.0
0.15.0-dev
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.name = .zstbi,
.fingerprint = 0x3c971054ff1a412f,
.version = "0.11.0-dev",
.minimum_zig_version = "0.13.0-dev.351+64ef45eb0",
.minimum_zig_version = "0.15.0-dev.552+bc2f7c754",
.paths = .{
"build.zig",
"build.zig.zon",
Expand Down
8 changes: 4 additions & 4 deletions src/zstbi.zig
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ pub fn setFlipVerticallyOnWrite(should_flip: bool) void {
var mem_allocator: ?std.mem.Allocator = null;
var mem_allocations: ?std.AutoHashMap(usize, usize) = null;
var mem_mutex: std.Thread.Mutex = .{};
const mem_alignment = 16;
const mem_alignment = std.mem.Alignment.@"16";
Copy link
Preview

Copilot AI Jul 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The quoted identifier syntax @"16" is unnecessary here. Use the cleaner syntax: std.mem.Alignment.from(16) or std.mem.Alignment.of(16) if available in Zig 0.15.

Copilot uses AI. Check for mistakes.


extern var zstbiMallocPtr: ?*const fn (size: usize) callconv(.C) ?*anyopaque;
extern var zstbiwMallocPtr: ?*const fn (size: usize) callconv(.C) ?*anyopaque;
Expand Down Expand Up @@ -409,9 +409,9 @@ fn zstbiRealloc(ptr: ?*anyopaque, size: usize) callconv(.C) ?*anyopaque {

const old_size = if (ptr != null) mem_allocations.?.get(@intFromPtr(ptr.?)).? else 0;
const old_mem = if (old_size > 0)
@as([*]align(mem_alignment) u8, @ptrCast(@alignCast(ptr)))[0..old_size]
@as([*]align(mem_alignment.toByteUnits()) u8, @ptrCast(@alignCast(ptr)))[0..old_size]
else
@as([*]align(mem_alignment) u8, undefined)[0..0];
@as([*]align(mem_alignment.toByteUnits()) u8, undefined)[0..0];

const new_mem = mem_allocator.?.realloc(old_mem, size) catch @panic("zstbi: out of memory");

Expand All @@ -434,7 +434,7 @@ fn zstbiFree(maybe_ptr: ?*anyopaque) callconv(.C) void {
defer mem_mutex.unlock();

const size = mem_allocations.?.fetchRemove(@intFromPtr(ptr)).?.value;
const mem = @as([*]align(mem_alignment) u8, @ptrCast(@alignCast(ptr)))[0..size];
const mem = @as([*]align(mem_alignment.toByteUnits()) u8, @ptrCast(@alignCast(ptr)))[0..size];
mem_allocator.?.free(mem);
}
}
Expand Down