WithDecoderMaxMemory allows to set a maximum decoded size for in-memory non-streaming operations or maximum window size for streaming operations. This can be used to control memory usage of potentially hostile content. Maximum is 1 << 63 bytes. Default is 64GiB. Can be changed with ResetWithOptions.
(n uint64)
| 88 | // Maximum is 1 << 63 bytes. Default is 64GiB. |
| 89 | // Can be changed with ResetWithOptions. |
| 90 | func WithDecoderMaxMemory(n uint64) DOption { |
| 91 | return func(o *decoderOptions) error { |
| 92 | if n == 0 { |
| 93 | return errors.New("WithDecoderMaxMemory must be at least 1") |
| 94 | } |
| 95 | if n > 1<<63 { |
| 96 | return errors.New("WithDecoderMaxmemory must be less than 1 << 63") |
| 97 | } |
| 98 | o.maxDecodedSize = n |
| 99 | return nil |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | // WithDecoderDicts allows to register one or more dictionaries for the decoder. |
| 104 | // |
no outgoing calls
searching dependent graphs…