summaryrefslogtreecommitdiff
path: root/libarchive/archive_write_add_filter_zstd.c
diff options
context:
space:
mode:
authorPetr Malat <oss@malat.biz>2021-12-23 11:47:04 +0100
committerPetr Malat <oss@malat.biz>2021-12-23 12:23:16 +0100
commit406165fcb2a1b3a49983d9e68fcbee9d3640fbea (patch)
tree3d62967daca48d0575f082c73c0c5cd4abd03367 /libarchive/archive_write_add_filter_zstd.c
parent411284e3f5819a5726622f3f129ebf2859f2d46b (diff)
downloadlibarchive-406165fcb2a1b3a49983d9e68fcbee9d3640fbea.tar.gz
Support libzstd compiled with compressor disabled
ZSTD library can be compiled with the compressor disabled, which is handy on space restricted systems as the compressor accounts for more than two thirds of the library size. Detect this case and use libzstd for the decompression only. Compression will be done using zstd binary if it's available.
Diffstat (limited to 'libarchive/archive_write_add_filter_zstd.c')
-rw-r--r--libarchive/archive_write_add_filter_zstd.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/libarchive/archive_write_add_filter_zstd.c b/libarchive/archive_write_add_filter_zstd.c
index 41e4c520..e85b7669 100644
--- a/libarchive/archive_write_add_filter_zstd.c
+++ b/libarchive/archive_write_add_filter_zstd.c
@@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$");
struct private_data {
int compression_level;
int threads;
-#if HAVE_ZSTD_H && HAVE_LIBZSTD
+#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
ZSTD_CStream *cstream;
int64_t total_in;
ZSTD_outBuffer out;
@@ -77,7 +77,7 @@ static int archive_compressor_zstd_write(struct archive_write_filter *,
const void *, size_t);
static int archive_compressor_zstd_close(struct archive_write_filter *);
static int archive_compressor_zstd_free(struct archive_write_filter *);
-#if HAVE_ZSTD_H && HAVE_LIBZSTD
+#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
static int drive_compressor(struct archive_write_filter *,
struct private_data *, int, const void *, size_t);
#endif
@@ -109,7 +109,7 @@ archive_write_add_filter_zstd(struct archive *_a)
f->name = "zstd";
data->compression_level = CLEVEL_DEFAULT;
data->threads = 0;
-#if HAVE_ZSTD_H && HAVE_LIBZSTD
+#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
data->cstream = ZSTD_createCStream();
if (data->cstream == NULL) {
free(data);
@@ -136,7 +136,7 @@ static int
archive_compressor_zstd_free(struct archive_write_filter *f)
{
struct private_data *data = (struct private_data *)f->data;
-#if HAVE_ZSTD_H && HAVE_LIBZSTD
+#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
ZSTD_freeCStream(data->cstream);
free(data->out.dst);
#else
@@ -189,7 +189,7 @@ archive_compressor_zstd_options(struct archive_write_filter *f, const char *key,
if (string_is_numeric(value) != ARCHIVE_OK) {
return (ARCHIVE_WARN);
}
-#if HAVE_ZSTD_H && HAVE_LIBZSTD
+#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
maximum = ZSTD_maxCLevel();
#if ZSTD_VERSION_NUMBER >= MINVER_MINCLEVEL
if (ZSTD_versionNumber() >= MINVER_MINCLEVEL) {
@@ -228,7 +228,7 @@ archive_compressor_zstd_options(struct archive_write_filter *f, const char *key,
return (ARCHIVE_WARN);
}
-#if HAVE_ZSTD_H && HAVE_LIBZSTD
+#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
/*
* Setup callback.
*/
@@ -353,7 +353,7 @@ drive_compressor(struct archive_write_filter *f,
}
}
-#else /* HAVE_ZSTD_H && HAVE_LIBZSTD */
+#else /* HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR */
static int
archive_compressor_zstd_open(struct archive_write_filter *f)
@@ -415,4 +415,4 @@ archive_compressor_zstd_close(struct archive_write_filter *f)
return __archive_write_program_close(f, data->pdata);
}
-#endif /* HAVE_ZSTD_H && HAVE_LIBZSTD */
+#endif /* HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR */