From 0b6129f1aef2b8215fee77cc88da9ad9dcbe4525 Mon Sep 17 00:00:00 2001 From: "Caleb J. Gardner" Date: Sun, 8 Mar 2026 22:15:28 -0500 Subject: [PATCH] Switch to zlib-ng --- build.zig | 2 +- src/decomp.zig | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.zig b/build.zig index eec0868..55da7bd 100644 --- a/build.zig +++ b/build.zig @@ -21,7 +21,7 @@ pub fn build(b: *std.Build) !void { }); mod.addOptions("config", zig_squashfs_options); if (use_c_libs_option == true) { - mod.linkSystemLibrary("zlib", .{ .preferred_link_mode = .static }); + mod.linkSystemLibrary("zlib-ng", .{ .preferred_link_mode = .static }); mod.linkSystemLibrary("lzma", .{ .preferred_link_mode = .static }); if (allow_lzo == true) mod.linkSystemLibrary("minilzo", .{ .preferred_link_mode = .static }); diff --git a/src/decomp.zig b/src/decomp.zig index 76ac5b9..0928e09 100644 --- a/src/decomp.zig +++ b/src/decomp.zig @@ -11,7 +11,7 @@ const config = if (builtin.is_test) .{ } else @import("config"); const c = @cImport({ - @cInclude("zlib.h"); + @cInclude("zlib-ng.h"); @cInclude("lzma.h"); @cInclude("lz4.h"); @cInclude("zstd.h"); @@ -43,7 +43,7 @@ fn zigGzip(alloc: std.mem.Allocator, in: []u8, out: []u8) anyerror!usize { fn cGzip(alloc: std.mem.Allocator, in: []u8, out: []u8) anyerror!usize { _ = alloc; var out_len: usize = out.len; - const res = c.uncompress(out.ptr, &out_len, in.ptr, in.len); + const res = c.zng_uncompress2(out.ptr, &out_len, in.ptr, in.len); return switch (res) { c.Z_OK => out_len, c.Z_MEM_ERROR => error.NotEnoughMemory, @@ -137,6 +137,7 @@ fn cXz(alloc: std.mem.Allocator, in: []u8, out: []u8) anyerror!usize { .avail_in = in.len, .next_out = out.ptr, .avail_out = out.len, + // .allocator = _, TODO: create a custom allocator based on alloc, }; var res = c.lzma_stream_decoder(&stream, in.len * 2, 0); switch (res) {