aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-06-05 17:51:38 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-06-07 02:44:10 +0200
commit9c61e28d9b9faf6bd8b4e9b8d28ed79b441fbeb6 (patch)
treefe04b883ca1343e8d088ffa802b488d435bf086e /lib
parent09727f7523761cf57d8b90042af78088f0d4ef7f (diff)
block processor: add an internal common cleanup function
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/sqfs/block_processor/common.c16
-rw-r--r--lib/sqfs/block_processor/internal.h2
-rw-r--r--lib/sqfs/block_processor/serial.c9
-rw-r--r--lib/sqfs/block_processor/winpthread.c4
4 files changed, 20 insertions, 11 deletions
diff --git a/lib/sqfs/block_processor/common.c b/lib/sqfs/block_processor/common.c
index 6171632..11cbd51 100644
--- a/lib/sqfs/block_processor/common.c
+++ b/lib/sqfs/block_processor/common.c
@@ -270,6 +270,22 @@ fail_outblk:
return err;
}
+void block_processor_cleanup(sqfs_block_processor_t *base)
+{
+ sqfs_block_t *it;
+
+ if (base->frag_block != NULL)
+ release_old_block(base, base->frag_block);
+
+ free(base->blk_current);
+
+ while (base->free_list != NULL) {
+ it = base->free_list;
+ base->free_list = it->next;
+ free(it);
+ }
+}
+
int block_processor_init(sqfs_block_processor_t *base, size_t max_block_size,
sqfs_compressor_t *cmp, sqfs_block_writer_t *wr,
sqfs_frag_table_t *tbl)
diff --git a/lib/sqfs/block_processor/internal.h b/lib/sqfs/block_processor/internal.h
index 496d415..d50a452 100644
--- a/lib/sqfs/block_processor/internal.h
+++ b/lib/sqfs/block_processor/internal.h
@@ -91,6 +91,8 @@ struct sqfs_block_processor_t {
int (*sync)(sqfs_block_processor_t *proc);
};
+SQFS_INTERNAL void block_processor_cleanup(sqfs_block_processor_t *base);
+
SQFS_INTERNAL int block_processor_init(sqfs_block_processor_t *base,
size_t max_block_size,
sqfs_compressor_t *cmp,
diff --git a/lib/sqfs/block_processor/serial.c b/lib/sqfs/block_processor/serial.c
index 7b3825d..f56f3cb 100644
--- a/lib/sqfs/block_processor/serial.c
+++ b/lib/sqfs/block_processor/serial.c
@@ -28,14 +28,7 @@ static void block_processor_destroy(sqfs_object_t *obj)
{
sqfs_block_processor_t *proc = (sqfs_block_processor_t *)obj;
- free_block_list(proc->free_list);
-
- if (proc->frag_block != NULL) {
- free_block_list(proc->frag_block->frag_list);
- free(proc->frag_block);
- }
-
- free(proc->blk_current);
+ block_processor_cleanup(proc);
free(proc);
}
diff --git a/lib/sqfs/block_processor/winpthread.c b/lib/sqfs/block_processor/winpthread.c
index 1519257..3531a3b 100644
--- a/lib/sqfs/block_processor/winpthread.c
+++ b/lib/sqfs/block_processor/winpthread.c
@@ -219,9 +219,7 @@ static void block_processor_destroy(sqfs_object_t *obj)
free_blk_list(proc->proc_queue);
free_blk_list(proc->io_queue);
free_blk_list(proc->done);
- free_blk_list(proc->base.free_list);
- free(proc->base.blk_current);
- free(proc->base.frag_block);
+ block_processor_cleanup(&proc->base);
free(proc);
}