summaryrefslogtreecommitdiff
path: root/lib/comp/lz4.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/lz4.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/lz4.c')
-rw-r--r--lib/comp/lz4.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/comp/lz4.c b/lib/comp/lz4.c
index ffa84dc..abb6c5c 100644
--- a/lib/comp/lz4.c
+++ b/lib/comp/lz4.c
@@ -97,6 +97,19 @@ static ssize_t lz4_uncomp_block(compressor_t *base, const uint8_t *in,
return ret;
}
+static compressor_t *lz4_create_copy(compressor_t *cmp)
+{
+ lz4_compressor_t *lz4 = malloc(sizeof(*lz4));
+
+ if (lz4 == NULL) {
+ perror("creating additional lz4 compressor");
+ return NULL;
+ }
+
+ memcpy(lz4, cmp, sizeof(*lz4));
+ return (compressor_t *)lz4;
+}
+
static void lz4_destroy(compressor_t *base)
{
free(base);
@@ -131,6 +144,7 @@ compressor_t *create_lz4_compressor(bool compress, size_t block_size,
base->do_block = compress ? lz4_comp_block : lz4_uncomp_block;
base->write_options = lz4_write_options;
base->read_options = lz4_read_options;
+ base->create_copy = lz4_create_copy;
return base;
}