summaryrefslogtreecommitdiff
path: root/lib/comp/xz.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-12 18:25:52 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-16 16:47:24 +0200
commit2f22a35e843a24f0ad5f31644133d64648fe4efc (patch)
tree7175b11355ea988c022d7e87b27f6676c5d2d181 /lib/comp/xz.c
parent008990af4d8b0cfa03fcb2c5fa2ba461dad71b18 (diff)
Add deep-copy function to compressor interface
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/comp/xz.c')
-rw-r--r--lib/comp/xz.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/comp/xz.c b/lib/comp/xz.c
index 3e63050..d38aab6 100644
--- a/lib/comp/xz.c
+++ b/lib/comp/xz.c
@@ -195,6 +195,19 @@ static ssize_t xz_uncomp_block(compressor_t *base, const uint8_t *in,
return -1;
}
+static compressor_t *xz_create_copy(compressor_t *cmp)
+{
+ xz_compressor_t *xz = malloc(sizeof(*xz));
+
+ if (xz == NULL) {
+ perror("creating additional xz compressor");
+ return NULL;
+ }
+
+ memcpy(xz, cmp, sizeof(*xz));
+ return (compressor_t *)xz;
+}
+
static void xz_destroy(compressor_t *base)
{
free(base);
@@ -318,6 +331,7 @@ compressor_t *create_xz_compressor(bool compress, size_t block_size,
base->do_block = compress ? xz_comp_block : xz_uncomp_block;
base->write_options = xz_write_options;
base->read_options = xz_read_options;
+ base->create_copy = xz_create_copy;
return base;
}