Skip to content

Commit

Permalink
ffi: avoid loading 2 different zlib libraries (#1912)
Browse files Browse the repository at this point in the history
Avoid loading the system version instead of ours.
  • Loading branch information
benoit-pierre authored Aug 24, 2024
1 parent 1ed4685 commit 9324da2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ffi/zipwriter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ local ffi = require "ffi"
require "ffi/zlib_h"

-- We only need to wrap 2 zlib functions to make a zip file
local _zlib = ffi.load(ffi.os == "Windows" and "zlib1" or "z")
local _zlib
if ffi.os == "Windows" then
_zlib = ffi.load("libs/libz1.dll")
elseif ffi.os == "OSX" then
_zlib = ffi.load("libs/libz.1.dylib")
else
_zlib = ffi.load("libs/libz.so.1")
end
local function zlibCompress(data)
local n = _zlib.compressBound(#data)
local buf = ffi.new("uint8_t[?]", n)
Expand Down

0 comments on commit 9324da2

Please sign in to comment.