summaryrefslogtreecommitdiff
path: root/lib/sqfs/block_processor
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqfs/block_processor')
-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);
}