From 4160b50a0b4c51f8b7191928cdf38d9fb0147fe2 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 4 Dec 2022 00:39:47 +0100 Subject: Add a helper function to initialize libsquashfs objects Signed-off-by: David Oberhollenzer --- lib/common/comp_lzo.c | 4 ++-- lib/common/data_writer_ostream.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/common') diff --git a/lib/common/comp_lzo.c b/lib/common/comp_lzo.c index 92a081c..2021d34 100644 --- a/lib/common/comp_lzo.c +++ b/lib/common/comp_lzo.c @@ -266,6 +266,8 @@ int lzo_compressor_create(const sqfs_compressor_config_t *cfg, if (lzo == NULL) return SQFS_ERROR_ALLOC; + sqfs_object_init(lzo, lzo_destroy, lzo_create_copy); + lzo->block_size = cfg->block_size; lzo->algorithm = cfg->opt.lzo.algorithm; lzo->level = cfg->level; @@ -277,8 +279,6 @@ int lzo_compressor_create(const sqfs_compressor_config_t *cfg, lzo_uncomp_block : lzo_comp_block; base->write_options = lzo_write_options; base->read_options = lzo_read_options; - ((sqfs_object_t *)base)->copy = lzo_create_copy; - ((sqfs_object_t *)base)->destroy = lzo_destroy; *out = base; return 0; diff --git a/lib/common/data_writer_ostream.c b/lib/common/data_writer_ostream.c index 94a04f2..fbd0431 100644 --- a/lib/common/data_writer_ostream.c +++ b/lib/common/data_writer_ostream.c @@ -64,7 +64,6 @@ ostream_t *data_writer_ostream_create(const char *filename, int flags) { data_writer_ostream_t *strm = calloc(1, sizeof(*strm)); - sqfs_object_t *obj = (sqfs_object_t *)strm; ostream_t *base = (ostream_t *)strm; int ret; @@ -73,6 +72,8 @@ ostream_t *data_writer_ostream_create(const char *filename, return NULL; } + sqfs_object_init(strm, stream_destroy, NULL); + ret = sqfs_block_processor_begin_file(proc, inode, NULL, flags); if (ret != 0) { @@ -86,6 +87,5 @@ ostream_t *data_writer_ostream_create(const char *filename, base->append = stream_append; base->flush = stream_flush; base->get_filename = stream_get_filename; - obj->destroy = stream_destroy; return base; } -- cgit v1.2.3