summaryrefslogtreecommitdiff
path: root/lib/comp/lzo.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/lzo.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/lzo.c')
-rw-r--r--lib/comp/lzo.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/comp/lzo.c b/lib/comp/lzo.c
index 98cc200..66c2f59 100644
--- a/lib/comp/lzo.c
+++ b/lib/comp/lzo.c
@@ -177,6 +177,22 @@ static ssize_t lzo_uncomp_block(compressor_t *base, const uint8_t *in,
return len;
}
+static compressor_t *lzo_create_copy(compressor_t *cmp)
+{
+ lzo_compressor_t *other = (lzo_compressor_t *)cmp;
+ lzo_compressor_t *lzo;
+
+ lzo = calloc(1, sizeof(*lzo) + lzo_algs[other->algorithm].bufsize);
+
+ if (lzo == NULL) {
+ perror("creating additional lzo compressor");
+ return NULL;
+ }
+
+ memcpy(lzo, other, sizeof(*lzo));
+ return (compressor_t *)lzo;
+}
+
static void lzo_destroy(compressor_t *base)
{
free(base);
@@ -281,6 +297,7 @@ compressor_t *create_lzo_compressor(bool compress, size_t block_size,
base->do_block = compress ? lzo_comp_block : lzo_uncomp_block;
base->write_options = lzo_write_options;
base->read_options = lzo_read_options;
+ base->create_copy = lzo_create_copy;
return base;
}