Skip to content

Commit 57b82a3

Browse files
committed
Fixes for zig 0.15.1
1 parent a70604a commit 57b82a3

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

build.zig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ pub fn build(b: *std.Build) void {
4242

4343
const tests = b.addTest(.{
4444
.name = "zstbi-tests",
45-
.root_source_file = b.path("src/zstbi.zig"),
46-
.target = target,
47-
.optimize = optimize,
45+
.root_module = b.createModule(.{
46+
.root_source_file = b.path("src/zstbi.zig"),
47+
.target = target,
48+
.optimize = optimize,
49+
}),
4850
});
4951
tests.root_module.addImport("zstbi", zstbi);
5052
b.installArtifact(tests);

build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.name = .zstbi,
33
.fingerprint = 0x3c971054ff1a412f,
44
.version = "0.11.0-dev",
5-
.minimum_zig_version = "0.14.0",
5+
.minimum_zig_version = "0.15.1",
66
.paths = .{
77
"build.zig",
88
"build.zig.zon",

src/zstbi.zig

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ pub const Image = struct {
312312

313313
pub fn writeToFn(
314314
image: Image,
315-
write_fn: *const fn (ctx: ?*anyopaque, data: ?*anyopaque, size: c_int) callconv(.C) void,
315+
write_fn: *const fn (ctx: ?*anyopaque, data: ?*anyopaque, size: c_int) callconv(.c) void,
316316
context: ?*anyopaque,
317317
image_format: ImageWriteFormat,
318318
) ImageWriteError!void {
@@ -382,16 +382,16 @@ var mem_allocations: ?std.AutoHashMap(usize, usize) = null;
382382
var mem_mutex: std.Thread.Mutex = .{};
383383
const mem_alignment = 16;
384384

385-
extern var zstbiMallocPtr: ?*const fn (size: usize) callconv(.C) ?*anyopaque;
386-
extern var zstbiwMallocPtr: ?*const fn (size: usize) callconv(.C) ?*anyopaque;
385+
extern var zstbiMallocPtr: ?*const fn (size: usize) callconv(.c) ?*anyopaque;
386+
extern var zstbiwMallocPtr: ?*const fn (size: usize) callconv(.c) ?*anyopaque;
387387

388-
fn zstbiMalloc(size: usize) callconv(.C) ?*anyopaque {
388+
fn zstbiMalloc(size: usize) callconv(.c) ?*anyopaque {
389389
mem_mutex.lock();
390390
defer mem_mutex.unlock();
391391

392392
const mem = mem_allocator.?.alignedAlloc(
393393
u8,
394-
mem_alignment,
394+
.fromByteUnits(mem_alignment),
395395
size,
396396
) catch @panic("zstbi: out of memory");
397397

@@ -400,10 +400,10 @@ fn zstbiMalloc(size: usize) callconv(.C) ?*anyopaque {
400400
return mem.ptr;
401401
}
402402

403-
extern var zstbiReallocPtr: ?*const fn (ptr: ?*anyopaque, size: usize) callconv(.C) ?*anyopaque;
404-
extern var zstbiwReallocPtr: ?*const fn (ptr: ?*anyopaque, size: usize) callconv(.C) ?*anyopaque;
403+
extern var zstbiReallocPtr: ?*const fn (ptr: ?*anyopaque, size: usize) callconv(.c) ?*anyopaque;
404+
extern var zstbiwReallocPtr: ?*const fn (ptr: ?*anyopaque, size: usize) callconv(.c) ?*anyopaque;
405405

406-
fn zstbiRealloc(ptr: ?*anyopaque, size: usize) callconv(.C) ?*anyopaque {
406+
fn zstbiRealloc(ptr: ?*anyopaque, size: usize) callconv(.c) ?*anyopaque {
407407
mem_mutex.lock();
408408
defer mem_mutex.unlock();
409409

@@ -425,10 +425,10 @@ fn zstbiRealloc(ptr: ?*anyopaque, size: usize) callconv(.C) ?*anyopaque {
425425
return new_mem.ptr;
426426
}
427427

428-
extern var zstbiFreePtr: ?*const fn (maybe_ptr: ?*anyopaque) callconv(.C) void;
429-
extern var zstbiwFreePtr: ?*const fn (maybe_ptr: ?*anyopaque) callconv(.C) void;
428+
extern var zstbiFreePtr: ?*const fn (maybe_ptr: ?*anyopaque) callconv(.c) void;
429+
extern var zstbiwFreePtr: ?*const fn (maybe_ptr: ?*anyopaque) callconv(.c) void;
430430

431-
fn zstbiFree(maybe_ptr: ?*anyopaque) callconv(.C) void {
431+
fn zstbiFree(maybe_ptr: ?*anyopaque) callconv(.c) void {
432432
if (maybe_ptr) |ptr| {
433433
mem_mutex.lock();
434434
defer mem_mutex.unlock();
@@ -439,15 +439,15 @@ fn zstbiFree(maybe_ptr: ?*anyopaque) callconv(.C) void {
439439
}
440440
}
441441

442-
extern var zstbirMallocPtr: ?*const fn (size: usize, maybe_context: ?*anyopaque) callconv(.C) ?*anyopaque;
442+
extern var zstbirMallocPtr: ?*const fn (size: usize, maybe_context: ?*anyopaque) callconv(.c) ?*anyopaque;
443443

444-
fn zstbirMalloc(size: usize, _: ?*anyopaque) callconv(.C) ?*anyopaque {
444+
fn zstbirMalloc(size: usize, _: ?*anyopaque) callconv(.c) ?*anyopaque {
445445
return zstbiMalloc(size);
446446
}
447447

448-
extern var zstbirFreePtr: ?*const fn (maybe_ptr: ?*anyopaque, maybe_context: ?*anyopaque) callconv(.C) void;
448+
extern var zstbirFreePtr: ?*const fn (maybe_ptr: ?*anyopaque, maybe_context: ?*anyopaque) callconv(.c) void;
449449

450-
fn zstbirFree(maybe_ptr: ?*anyopaque, _: ?*anyopaque) callconv(.C) void {
450+
fn zstbirFree(maybe_ptr: ?*anyopaque, _: ?*anyopaque) callconv(.c) void {
451451
zstbiFree(maybe_ptr);
452452
}
453453

@@ -540,7 +540,7 @@ extern fn stbi_write_png(
540540
) c_int;
541541

542542
extern fn stbi_write_png_to_func(
543-
func: *const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.C) void,
543+
func: *const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.c) void,
544544
context: ?*anyopaque,
545545
w: c_int,
546546
h: c_int,
@@ -550,7 +550,7 @@ extern fn stbi_write_png_to_func(
550550
) c_int;
551551

552552
extern fn stbi_write_jpg_to_func(
553-
func: *const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.C) void,
553+
func: *const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.c) void,
554554
context: ?*anyopaque,
555555
x: c_int,
556556
y: c_int,

0 commit comments

Comments
 (0)