mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 16:32:11 +01:00
Increase cgolz4 Writer buf len for older lz4 libs
This commit is contained in:
1 parent
6f7e9dfa26
commit
7d4a3a127d
2 files changed
+13
-1
No files matched your search
@@ -346,6 +346,12 @@ func (c *WriterRecycler) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func minDstLenForBlockMaxLen() uint64 {
|
||||
return uint64(C.cgolz4_compress_min_dst_len(C.uint32_t(blockMaxLen)))
|
||||
}
|
||||
|
||||
const writerBufLen = 2*blockMaxLen + 16
|
||||
|
||||
// Writer compresses to the lz4 format.
|
||||
//
|
||||
// Compressed bytes may be buffered and not sent to the underlying io.Writer
|
||||
@@ -353,7 +359,7 @@ func (c *WriterRecycler) Close() error {
|
||||
//
|
||||
// The zero value is not usable until Reset is called.
|
||||
type Writer struct {
|
||||
buf [2 * blockMaxLen]byte
|
||||
buf [writerBufLen]byte
|
||||
j uint32
|
||||
w io.Writer
|
||||
begun bool
|
||||
|
||||
@@ -89,3 +89,9 @@ func TestRoundTrip(tt *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWriterBufIsLargeEnough(tt *testing.T) {
|
||||
if m := minDstLenForBlockMaxLen(); writerBufLen < m {
|
||||
tt.Fatalf("writerBufLen: got %d, want >= %d", writerBufLen, m)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user