(in []byte)
| 132 | } |
| 133 | |
| 134 | func (s *Scratch) prepare(in []byte) (*Scratch, error) { |
| 135 | if len(in) > BlockSizeMax { |
| 136 | return nil, ErrTooBig |
| 137 | } |
| 138 | if s == nil { |
| 139 | s = &Scratch{} |
| 140 | } |
| 141 | if s.MaxSymbolValue == 0 { |
| 142 | s.MaxSymbolValue = maxSymbolValue |
| 143 | } |
| 144 | if s.TableLog == 0 { |
| 145 | s.TableLog = tableLogDefault |
| 146 | } |
| 147 | if s.TableLog > tableLogMax || s.TableLog < minTablelog { |
| 148 | return nil, fmt.Errorf(" invalid tableLog %d (%d -> %d)", s.TableLog, minTablelog, tableLogMax) |
| 149 | } |
| 150 | if s.MaxDecodedSize <= 0 || s.MaxDecodedSize > BlockSizeMax { |
| 151 | s.MaxDecodedSize = BlockSizeMax |
| 152 | } |
| 153 | if s.clearCount && s.maxCount == 0 { |
| 154 | for i := range s.count { |
| 155 | s.count[i] = 0 |
| 156 | } |
| 157 | s.clearCount = false |
| 158 | } |
| 159 | if cap(s.Out) == 0 { |
| 160 | s.Out = make([]byte, 0, len(in)) |
| 161 | } |
| 162 | s.Out = s.Out[:0] |
| 163 | |
| 164 | s.OutTable = nil |
| 165 | s.OutData = nil |
| 166 | if cap(s.nodes) < huffNodesLen+1 { |
| 167 | s.nodes = make([]nodeElt, 0, huffNodesLen+1) |
| 168 | } |
| 169 | s.nodes = s.nodes[:0] |
| 170 | if s.fse == nil { |
| 171 | s.fse = &fse.Scratch{} |
| 172 | } |
| 173 | s.srcLen = len(in) |
| 174 | |
| 175 | return s, nil |
| 176 | } |
| 177 | |
| 178 | type cTable []cTableEntry |
| 179 |
no outgoing calls
no test coverage detected