| 196 | } |
| 197 | |
| 198 | Result<FlushResult> Flush(int64_t output_len, uint8_t* output) override { |
| 199 | auto dst = output; |
| 200 | auto dst_capacity = static_cast<size_t>(output_len); |
| 201 | size_t ret; |
| 202 | int64_t bytes_written = 0; |
| 203 | |
| 204 | BEGIN_COMPRESS(dst, dst_capacity, (FlushResult{0, true})); |
| 205 | |
| 206 | if (dst_capacity < LZ4F_compressBound(0, &prefs_)) { |
| 207 | // Output too small to flush into |
| 208 | return FlushResult{bytes_written, true}; |
| 209 | } |
| 210 | |
| 211 | ret = LZ4F_flush(ctx_, dst, dst_capacity, nullptr /* options */); |
| 212 | if (LZ4F_isError(ret)) { |
| 213 | return LZ4Error(ret, "LZ4 flush failed: "); |
| 214 | } |
| 215 | bytes_written += static_cast<int64_t>(ret); |
| 216 | DCHECK_LE(bytes_written, output_len); |
| 217 | return FlushResult{bytes_written, false}; |
| 218 | } |
| 219 | |
| 220 | Result<EndResult> End(int64_t output_len, uint8_t* output) override { |
| 221 | auto dst = output; |
no test coverage detected