| // SPDX-License-Identifier: GPL-2.0+ |
| * Copyright 2021 Google LLC |
| #define LOG_CATEGORY LOGC_BOOT |
| int zstd_decompress(struct abuf *in, struct abuf *out) |
| wsize = ZSTD_DStreamWorkspaceBound(abuf_size(in)); |
| workspace = malloc(wsize); |
| debug("%s: cannot allocate workspace of size %zu\n", __func__, |
| dstream = ZSTD_initDStream(abuf_size(in), workspace, wsize); |
| log_err("%s: ZSTD_initDStream failed\n", __func__); |
| in_buf.src = abuf_data(in); |
| in_buf.size = abuf_size(in); |
| out_buf.dst = abuf_data(out); |
| out_buf.size = abuf_size(out); |
| res = ZSTD_decompressStream(dstream, &out_buf, &in_buf); |
| ret = ZSTD_getErrorCode(res); |
| log_err("ZSTD_decompressStream error %d\n", ret); |
| if (in_buf.pos >= abuf_size(in) || !res) |