summaryrefslogtreecommitdiff
path: root/vendor/github.com/klauspost/compress/zstd/encoder.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-11-22 16:21:19 +0100
committerGitHub <noreply@github.com>2019-11-22 16:21:19 +0100
commite4b805441b84017bdd313d412a4138e4fb41f3d3 (patch)
treebf4088f29a62893822c2696a43f2bebac52d8168 /vendor/github.com/klauspost/compress/zstd/encoder.go
parent22e7d7d86f945620bbc1bdd3aa9c4a9d3248fa1f (diff)
parent866391bb574f885549f5cf3cec965dc224cb84b3 (diff)
downloadpodman-e4b805441b84017bdd313d412a4138e4fb41f3d3.tar.gz
podman-e4b805441b84017bdd313d412a4138e4fb41f3d3.tar.bz2
podman-e4b805441b84017bdd313d412a4138e4fb41f3d3.zip
Merge pull request #4538 from containers/dependabot/go_modules/github.com/containers/storage-1.14.0
build(deps): bump github.com/containers/storage from 1.13.5 to 1.14.0
Diffstat (limited to 'vendor/github.com/klauspost/compress/zstd/encoder.go')
-rw-r--r--vendor/github.com/klauspost/compress/zstd/encoder.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/vendor/github.com/klauspost/compress/zstd/encoder.go b/vendor/github.com/klauspost/compress/zstd/encoder.go
index b7011be29..d79188271 100644
--- a/vendor/github.com/klauspost/compress/zstd/encoder.go
+++ b/vendor/github.com/klauspost/compress/zstd/encoder.go
@@ -59,6 +59,7 @@ type encoderState struct {
// NewWriter will create a new Zstandard encoder.
// If the encoder will be used for encoding blocks a nil writer can be used.
func NewWriter(w io.Writer, opts ...EOption) (*Encoder, error) {
+ initPredefined()
var e Encoder
e.o.setDefault()
for _, o := range opts {
@@ -393,12 +394,31 @@ func (e *Encoder) Close() error {
// EncodeAll will encode all input in src and append it to dst.
// This function can be called concurrently, but each call will only run on a single goroutine.
-// If empty input is given, nothing is returned.
+// If empty input is given, nothing is returned, unless WithZeroFrames is specified.
// Encoded blocks can be concatenated and the result will be the combined input stream.
// Data compressed with EncodeAll can be decoded with the Decoder,
// using either a stream or DecodeAll.
func (e *Encoder) EncodeAll(src, dst []byte) []byte {
if len(src) == 0 {
+ if e.o.fullZero {
+ // Add frame header.
+ fh := frameHeader{
+ ContentSize: 0,
+ WindowSize: MinWindowSize,
+ SingleSegment: true,
+ // Adding a checksum would be a waste of space.
+ Checksum: false,
+ DictID: 0,
+ }
+ dst, _ = fh.appendTo(dst)
+
+ // Write raw block as last one only.
+ var blk blockHeader
+ blk.setSize(0)
+ blk.setType(blockTypeRaw)
+ blk.setLast(true)
+ dst = blk.appendTo(dst)
+ }
return dst
}
e.init.Do(func() {