Skip to content

Commit 9cfdb39

Browse files
committed
New feature: compressor can take streams larger than typemax(UInt32) bytes
1 parent a777d8f commit 9cfdb39

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/compression.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,14 @@ end
169169
function TranscodingStreams.process(codec::CompressorCodec, input::Memory, output::Memory, error::Error)
170170
zstream = codec.zstream
171171
zstream.next_in = input.ptr
172-
zstream.avail_in = input.size
172+
avail_in = min(input.size, typemax(UInt32))
173+
zstream.avail_in = avail_in
173174
zstream.next_out = output.ptr
174-
zstream.avail_out = output.size
175-
code = deflate!(zstream, input.size > 0 ? Z_NO_FLUSH : Z_FINISH)
176-
Δin = Int(input.size - zstream.avail_in)
177-
Δout = Int(output.size - zstream.avail_out)
175+
avail_out = min(output.size, typemax(UInt32))
176+
zstream.avail_out = avail_out
177+
code = deflate!(zstream, zstream.avail_in > 0 ? Z_NO_FLUSH : Z_FINISH)
178+
Δin = Int(avail_in - zstream.avail_in)
179+
Δout = Int(avail_out - zstream.avail_out)
178180
if code == Z_OK
179181
return Δin, Δout, :ok
180182
elseif code == Z_STREAM_END

0 commit comments

Comments
 (0)