Lines Matching +full:data +full:- +full:size
1 // SPDX-License-Identifier: GPL-2.0
8 int zstd_init(struct zstd_data *data, int level) in zstd_init() argument
10 data->comp_level = level; in zstd_init()
11 data->dstream = NULL; in zstd_init()
12 data->cstream = NULL; in zstd_init()
16 int zstd_fini(struct zstd_data *data) in zstd_fini() argument
18 if (data->dstream) { in zstd_fini()
19 ZSTD_freeDStream(data->dstream); in zstd_fini()
20 data->dstream = NULL; in zstd_fini()
23 if (data->cstream) { in zstd_fini()
24 ZSTD_freeCStream(data->cstream); in zstd_fini()
25 data->cstream = NULL; in zstd_fini()
31 ssize_t zstd_compress_stream_to_records(struct zstd_data *data, void *dst, size_t dst_size, in zstd_compress_stream_to_records() argument
35 size_t ret, size, compressed = 0; in zstd_compress_stream_to_records() local
40 if (!data->cstream) { in zstd_compress_stream_to_records()
41 data->cstream = ZSTD_createCStream(); in zstd_compress_stream_to_records()
42 if (data->cstream == NULL) { in zstd_compress_stream_to_records()
44 return -1; in zstd_compress_stream_to_records()
47 ret = ZSTD_initCStream(data->cstream, data->comp_level); in zstd_compress_stream_to_records()
51 return -1; in zstd_compress_stream_to_records()
55 while (input.pos < input.size) { in zstd_compress_stream_to_records()
57 size = process_header(record, 0); in zstd_compress_stream_to_records()
58 compressed += size; in zstd_compress_stream_to_records()
59 dst += size; in zstd_compress_stream_to_records()
60 dst_size -= size; in zstd_compress_stream_to_records()
63 ret = ZSTD_compressStream(data->cstream, &output, &input); in zstd_compress_stream_to_records()
64 ZSTD_flushStream(data->cstream, &output); in zstd_compress_stream_to_records()
71 size = output.pos; in zstd_compress_stream_to_records()
72 size = process_header(record, size); in zstd_compress_stream_to_records()
73 compressed += size; in zstd_compress_stream_to_records()
74 dst += size; in zstd_compress_stream_to_records()
75 dst_size -= size; in zstd_compress_stream_to_records()
81 size_t zstd_decompress_stream(struct zstd_data *data, void *src, size_t src_size, in zstd_decompress_stream() argument
88 if (!data->dstream) { in zstd_decompress_stream()
89 data->dstream = ZSTD_createDStream(); in zstd_decompress_stream()
90 if (data->dstream == NULL) { in zstd_decompress_stream()
95 ret = ZSTD_initDStream(data->dstream); in zstd_decompress_stream()
102 while (input.pos < input.size) { in zstd_decompress_stream()
103 ret = ZSTD_decompressStream(data->dstream, &output, &input); in zstd_decompress_stream()
105 pr_err("failed to decompress (B): %zd -> %zd, dst_size %zd : %s\n", in zstd_decompress_stream()
106 src_size, output.size, dst_size, ZSTD_getErrorName(ret)); in zstd_decompress_stream()
110 output.size = dst_size - output.pos; in zstd_decompress_stream()