Skip to content

Commit 91bac86

Browse files
authored
reset a stream in startproc (#4)
* reset a stream in startproc * allow failures on nightly build
1 parent a870e22 commit 91bac86

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ os:
66
julia:
77
- 0.6
88
- nightly
9+
matrix:
10+
allow_failures:
11+
- julia: nightly
912
notifications:
1013
email: false
1114
# uncomment the following lines to override the default test script

src/compression.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ function TranscodingStreams.finalize(codec::ZstdCompression)
6363
return
6464
end
6565

66+
function TranscodingStreams.startproc(codec::ZstdCompression, mode::Symbol, error::Error)
67+
code = reset!(codec.cstream, 0 #=unknown source size=#)
68+
if iserror(code)
69+
error[] = ErrorException("zstd error")
70+
return :error
71+
end
72+
return :ok
73+
end
74+
6675
function TranscodingStreams.process(codec::ZstdCompression, input::Memory, output::Memory, error::Error)
6776
cstream = codec.cstream
6877
cstream.ibuffer.src = input.ptr

src/decompression.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ function TranscodingStreams.finalize(codec::ZstdDecompression)
5252
return
5353
end
5454

55+
function TranscodingStreams.startproc(codec::ZstdDecompression, mode::Symbol, error::Error)
56+
code = reset!(codec.dstream)
57+
if iserror(code)
58+
error[] = ErrorException("zstd error")
59+
return :error
60+
end
61+
return :ok
62+
end
63+
5564
function TranscodingStreams.process(codec::ZstdDecompression, input::Memory, output::Memory, error::Error)
5665
dstream = codec.dstream
5766
dstream.ibuffer.src = input.ptr

src/libzstd.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ function initialize!(cstream::CStream, level::Integer)
6060
return ccall((:ZSTD_initCStream, libzstd), Csize_t, (Ptr{Void}, Cint), cstream.ptr, level)
6161
end
6262

63+
function reset!(cstream::CStream, srcsize::Integer)
64+
return ccall((:ZSTD_resetCStream, libzstd), Csize_t, (Ptr{Void}, Culonglong), cstream.ptr, srcsize)
65+
end
66+
6367
function compress!(cstream::CStream)
6468
return ccall((:ZSTD_compressStream, libzstd), Csize_t, (Ptr{Void}, Ptr{Void}, Ptr{Void}), cstream.ptr, pointer_from_objref(cstream.obuffer), pointer_from_objref(cstream.ibuffer))
6569
end
@@ -91,6 +95,10 @@ function initialize!(dstream::DStream)
9195
return ccall((:ZSTD_initDStream, libzstd), Csize_t, (Ptr{Void},), dstream.ptr)
9296
end
9397

98+
function reset!(dstream::DStream)
99+
return ccall((:ZSTD_resetDStream, libzstd), Csize_t, (Ptr{Void},), dstream.ptr)
100+
end
101+
94102
function decompress!(dstream::DStream)
95103
return ccall((:ZSTD_decompressStream, libzstd), Csize_t, (Ptr{Void}, Ptr{Void}, Ptr{Void}), dstream.ptr, pointer_from_objref(dstream.obuffer), pointer_from_objref(dstream.ibuffer))
96104
end

0 commit comments

Comments
 (0)