diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-03-03 19:43:54 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-03-04 00:58:53 +0100 |
commit | 44c81eeffe9c8820b1009a7a5c728782aa5ebf40 (patch) | |
tree | 544eceb6dc5633018e5147c88ca9b07dd0fb54d9 /lib/sqfs/comp | |
parent | 6f47796dc0761fac359ec59ce26c7af5154e538d (diff) |
Add a generic copying mechanism to sqfs_object_t
This patch adds a deep-copy callback to sqfs_object_t and removes the
copying mechanism from sqfs_compressor_t. This is also interesting for
other types.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/comp')
-rw-r--r-- | lib/sqfs/comp/gzip.c | 6 | ||||
-rw-r--r-- | lib/sqfs/comp/lz4.c | 6 | ||||
-rw-r--r-- | lib/sqfs/comp/lzma.c | 6 | ||||
-rw-r--r-- | lib/sqfs/comp/xz.c | 6 | ||||
-rw-r--r-- | lib/sqfs/comp/zstd.c | 6 |
5 files changed, 15 insertions, 15 deletions
diff --git a/lib/sqfs/comp/gzip.c b/lib/sqfs/comp/gzip.c index 34164a6..351d733 100644 --- a/lib/sqfs/comp/gzip.c +++ b/lib/sqfs/comp/gzip.c @@ -221,7 +221,7 @@ static sqfs_s32 gzip_do_block(sqfs_compressor_t *base, const sqfs_u8 *in, return 0; } -static sqfs_compressor_t *gzip_create_copy(sqfs_compressor_t *cmp) +static sqfs_object_t *gzip_create_copy(const sqfs_object_t *cmp) { gzip_compressor_t *gzip = malloc(sizeof(*gzip)); int ret; @@ -244,7 +244,7 @@ static sqfs_compressor_t *gzip_create_copy(sqfs_compressor_t *cmp) return NULL; } - return (sqfs_compressor_t *)gzip; + return (sqfs_object_t *)gzip; } sqfs_compressor_t *gzip_compressor_create(const sqfs_compressor_config_t *cfg) @@ -283,7 +283,7 @@ sqfs_compressor_t *gzip_compressor_create(const sqfs_compressor_config_t *cfg) base->do_block = gzip_do_block; base->write_options = gzip_write_options; base->read_options = gzip_read_options; - base->create_copy = gzip_create_copy; + ((sqfs_object_t *)base)->copy = gzip_create_copy; ((sqfs_object_t *)base)->destroy = gzip_destroy; if (gzip->compress) { diff --git a/lib/sqfs/comp/lz4.c b/lib/sqfs/comp/lz4.c index f298c67..460ac44 100644 --- a/lib/sqfs/comp/lz4.c +++ b/lib/sqfs/comp/lz4.c @@ -116,7 +116,7 @@ static void lz4_get_configuration(const sqfs_compressor_t *base, cfg->flags |= SQFS_COMP_FLAG_UNCOMPRESS; } -static sqfs_compressor_t *lz4_create_copy(sqfs_compressor_t *cmp) +static sqfs_object_t *lz4_create_copy(const sqfs_object_t *cmp) { lz4_compressor_t *lz4 = malloc(sizeof(*lz4)); @@ -124,7 +124,7 @@ static sqfs_compressor_t *lz4_create_copy(sqfs_compressor_t *cmp) return NULL; memcpy(lz4, cmp, sizeof(*lz4)); - return (sqfs_compressor_t *)lz4; + return (sqfs_object_t *)lz4; } static void lz4_destroy(sqfs_object_t *base) @@ -155,7 +155,7 @@ sqfs_compressor_t *lz4_compressor_create(const sqfs_compressor_config_t *cfg) lz4_uncomp_block : lz4_comp_block; base->write_options = lz4_write_options; base->read_options = lz4_read_options; - base->create_copy = lz4_create_copy; + ((sqfs_object_t *)base)->copy = lz4_create_copy; ((sqfs_object_t *)base)->destroy = lz4_destroy; return base; } diff --git a/lib/sqfs/comp/lzma.c b/lib/sqfs/comp/lzma.c index 451a6ca..51afe65 100644 --- a/lib/sqfs/comp/lzma.c +++ b/lib/sqfs/comp/lzma.c @@ -156,14 +156,14 @@ static void lzma_get_configuration(const sqfs_compressor_t *base, cfg->flags |= SQFS_COMP_FLAG_UNCOMPRESS; } -static sqfs_compressor_t *lzma_create_copy(sqfs_compressor_t *cmp) +static sqfs_object_t *lzma_create_copy(const sqfs_object_t *cmp) { lzma_compressor_t *copy = malloc(sizeof(*copy)); if (copy != NULL) memcpy(copy, cmp, sizeof(*copy)); - return (sqfs_compressor_t *)copy; + return (sqfs_object_t *)copy; } static void lzma_destroy(sqfs_object_t *base) @@ -194,7 +194,7 @@ sqfs_compressor_t *lzma_compressor_create(const sqfs_compressor_config_t *cfg) lzma_uncomp_block : lzma_comp_block; base->write_options = lzma_write_options; base->read_options = lzma_read_options; - base->create_copy = lzma_create_copy; + ((sqfs_object_t *)base)->copy = lzma_create_copy; ((sqfs_object_t *)base)->destroy = lzma_destroy; return base; } diff --git a/lib/sqfs/comp/xz.c b/lib/sqfs/comp/xz.c index a600956..423604b 100644 --- a/lib/sqfs/comp/xz.c +++ b/lib/sqfs/comp/xz.c @@ -211,7 +211,7 @@ static void xz_get_configuration(const sqfs_compressor_t *base, cfg->flags |= SQFS_COMP_FLAG_UNCOMPRESS; } -static sqfs_compressor_t *xz_create_copy(sqfs_compressor_t *cmp) +static sqfs_object_t *xz_create_copy(const sqfs_object_t *cmp) { xz_compressor_t *xz = malloc(sizeof(*xz)); @@ -219,7 +219,7 @@ static sqfs_compressor_t *xz_create_copy(sqfs_compressor_t *cmp) return NULL; memcpy(xz, cmp, sizeof(*xz)); - return (sqfs_compressor_t *)xz; + return (sqfs_object_t *)xz; } static void xz_destroy(sqfs_object_t *base) @@ -253,7 +253,7 @@ sqfs_compressor_t *xz_compressor_create(const sqfs_compressor_config_t *cfg) xz_uncomp_block : xz_comp_block; base->write_options = xz_write_options; base->read_options = xz_read_options; - base->create_copy = xz_create_copy; + ((sqfs_object_t *)base)->copy = xz_create_copy; ((sqfs_object_t *)base)->destroy = xz_destroy; return base; } diff --git a/lib/sqfs/comp/zstd.c b/lib/sqfs/comp/zstd.c index e01f87d..12ddfdb 100644 --- a/lib/sqfs/comp/zstd.c +++ b/lib/sqfs/comp/zstd.c @@ -107,7 +107,7 @@ static void zstd_get_configuration(const sqfs_compressor_t *base, cfg->flags |= SQFS_COMP_FLAG_UNCOMPRESS; } -static sqfs_compressor_t *zstd_create_copy(sqfs_compressor_t *cmp) +static sqfs_object_t *zstd_create_copy(const sqfs_object_t *cmp) { zstd_compressor_t *zstd = malloc(sizeof(*zstd)); @@ -123,7 +123,7 @@ static sqfs_compressor_t *zstd_create_copy(sqfs_compressor_t *cmp) return NULL; } - return (sqfs_compressor_t *)zstd; + return (sqfs_object_t *)zstd; } static void zstd_destroy(sqfs_object_t *base) @@ -164,7 +164,7 @@ sqfs_compressor_t *zstd_compressor_create(const sqfs_compressor_config_t *cfg) zstd_uncomp_block : zstd_comp_block; base->write_options = zstd_write_options; base->read_options = zstd_read_options; - base->create_copy = zstd_create_copy; + ((sqfs_object_t *)base)->copy = zstd_create_copy; ((sqfs_object_t *)base)->destroy = zstd_destroy; return base; } |