WithDecoderMaxWindow allows to set a maximum window size for decodes. This allows rejecting packets that will cause big memory usage. The Decoder will likely allocate more memory based on the WithDecoderLowmem setting. If WithDecoderMaxMemory is set to a lower value, that will be used. Default is 51
(size uint64)
| 148 | // Default is 512MB, Maximum is ~3.75 TB as per zstandard spec. |
| 149 | // Can be changed with ResetWithOptions. |
| 150 | func WithDecoderMaxWindow(size uint64) DOption { |
| 151 | return func(o *decoderOptions) error { |
| 152 | if size < MinWindowSize { |
| 153 | return errors.New("WithMaxWindowSize must be at least 1KB, 1024 bytes") |
| 154 | } |
| 155 | if size > (1<<41)+7*(1<<38) { |
| 156 | return errors.New("WithMaxWindowSize must be less than (1<<41) + 7*(1<<38) ~ 3.75TB") |
| 157 | } |
| 158 | o.maxWindowSize = size |
| 159 | return nil |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | // WithDecodeAllCapLimit will limit DecodeAll to decoding cap(dst)-len(dst) bytes, |
| 164 | // or any size set in WithDecoderMaxMemory. |
no outgoing calls
searching dependent graphs…