summaryrefslogtreecommitdiff
path: root/lib/sqfs/comp
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-12 02:22:31 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-12 02:26:24 +0100
commit303680ebcd5adaac2934b63a0edc2d9d1a36d7fb (patch)
treebd2012dc6fa56f7259dbe2e5edd7ab3042f8e0a0 /lib/sqfs/comp
parentec7a522a520017327dd73b4d8e3787016ee1a31e (diff)
Implement a more explicit object system
Make every dynamically allocated, opaque data structure inherit from a common sqfs_object_t structure with common entry points (e.g. destroy). This removes tons of public API functions and replaces them with a simple sqfs_destroy instead. If semantics of the (until now implicit) object system need to be extended, it can be much more conveniantely done this way. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/comp')
-rw-r--r--lib/sqfs/comp/gzip.c4
-rw-r--r--lib/sqfs/comp/lz4.c4
-rw-r--r--lib/sqfs/comp/lzma.c4
-rw-r--r--lib/sqfs/comp/xz.c4
-rw-r--r--lib/sqfs/comp/zstd.c4
5 files changed, 10 insertions, 10 deletions
diff --git a/lib/sqfs/comp/gzip.c b/lib/sqfs/comp/gzip.c
index 7183e5a..37491bb 100644
--- a/lib/sqfs/comp/gzip.c
+++ b/lib/sqfs/comp/gzip.c
@@ -31,7 +31,7 @@ typedef struct {
gzip_options_t opt;
} gzip_compressor_t;
-static void gzip_destroy(sqfs_compressor_t *base)
+static void gzip_destroy(sqfs_object_t *base)
{
gzip_compressor_t *gzip = (gzip_compressor_t *)base;
@@ -264,10 +264,10 @@ sqfs_compressor_t *gzip_compressor_create(const sqfs_compressor_config_t *cfg)
gzip->compress = (cfg->flags & SQFS_COMP_FLAG_UNCOMPRESS) == 0;
gzip->block_size = cfg->block_size;
base->do_block = gzip_do_block;
- base->destroy = gzip_destroy;
base->write_options = gzip_write_options;
base->read_options = gzip_read_options;
base->create_copy = gzip_create_copy;
+ ((sqfs_object_t *)base)->destroy = gzip_destroy;
if (gzip->compress) {
ret = deflateInit2(&gzip->strm, cfg->opt.gzip.level,
diff --git a/lib/sqfs/comp/lz4.c b/lib/sqfs/comp/lz4.c
index dd9b6ac..7656d67 100644
--- a/lib/sqfs/comp/lz4.c
+++ b/lib/sqfs/comp/lz4.c
@@ -110,7 +110,7 @@ static sqfs_compressor_t *lz4_create_copy(sqfs_compressor_t *cmp)
return (sqfs_compressor_t *)lz4;
}
-static void lz4_destroy(sqfs_compressor_t *base)
+static void lz4_destroy(sqfs_object_t *base)
{
free(base);
}
@@ -132,11 +132,11 @@ sqfs_compressor_t *lz4_compressor_create(const sqfs_compressor_config_t *cfg)
lz4->high_compression = (cfg->flags & SQFS_COMP_FLAG_LZ4_HC) != 0;
- base->destroy = lz4_destroy;
base->do_block = (cfg->flags & SQFS_COMP_FLAG_UNCOMPRESS) ?
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)->destroy = lz4_destroy;
return base;
}
diff --git a/lib/sqfs/comp/lzma.c b/lib/sqfs/comp/lzma.c
index f7ab428..900cc14 100644
--- a/lib/sqfs/comp/lzma.c
+++ b/lib/sqfs/comp/lzma.c
@@ -153,7 +153,7 @@ static sqfs_compressor_t *lzma_create_copy(sqfs_compressor_t *cmp)
return (sqfs_compressor_t *)copy;
}
-static void lzma_destroy(sqfs_compressor_t *base)
+static void lzma_destroy(sqfs_object_t *base)
{
free(base);
}
@@ -176,11 +176,11 @@ sqfs_compressor_t *lzma_compressor_create(const sqfs_compressor_config_t *cfg)
if (lzma->block_size < SQFS_META_BLOCK_SIZE)
lzma->block_size = SQFS_META_BLOCK_SIZE;
- base->destroy = lzma_destroy;
base->do_block = (cfg->flags & SQFS_COMP_FLAG_UNCOMPRESS) ?
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)->destroy = lzma_destroy;
return base;
}
diff --git a/lib/sqfs/comp/xz.c b/lib/sqfs/comp/xz.c
index 91d48da..d612729 100644
--- a/lib/sqfs/comp/xz.c
+++ b/lib/sqfs/comp/xz.c
@@ -207,7 +207,7 @@ static sqfs_compressor_t *xz_create_copy(sqfs_compressor_t *cmp)
return (sqfs_compressor_t *)xz;
}
-static void xz_destroy(sqfs_compressor_t *base)
+static void xz_destroy(sqfs_object_t *base)
{
free(base);
}
@@ -233,11 +233,11 @@ sqfs_compressor_t *xz_compressor_create(const sqfs_compressor_config_t *cfg)
xz->flags = cfg->flags;
xz->dict_size = cfg->opt.xz.dict_size;
xz->block_size = cfg->block_size;
- base->destroy = xz_destroy;
base->do_block = (cfg->flags & SQFS_COMP_FLAG_UNCOMPRESS) ?
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)->destroy = xz_destroy;
return base;
}
diff --git a/lib/sqfs/comp/zstd.c b/lib/sqfs/comp/zstd.c
index a850033..4bd9456 100644
--- a/lib/sqfs/comp/zstd.c
+++ b/lib/sqfs/comp/zstd.c
@@ -110,7 +110,7 @@ static sqfs_compressor_t *zstd_create_copy(sqfs_compressor_t *cmp)
return (sqfs_compressor_t *)zstd;
}
-static void zstd_destroy(sqfs_compressor_t *base)
+static void zstd_destroy(sqfs_object_t *base)
{
zstd_compressor_t *zstd = (zstd_compressor_t *)base;
@@ -142,11 +142,11 @@ sqfs_compressor_t *zstd_compressor_create(const sqfs_compressor_config_t *cfg)
return NULL;
}
- base->destroy = zstd_destroy;
base->do_block = cfg->flags & SQFS_COMP_FLAG_UNCOMPRESS ?
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)->destroy = zstd_destroy;
return base;
}