summaryrefslogtreecommitdiff
path: root/lib/sqfs/block_processor/serial.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-14 17:56:40 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-15 19:24:59 +0100
commit9ac42164bc43bcdd47c0a8e5e59c662b2a136659 (patch)
tree4a2a18f859e41a3b4c2e4c1a1e0ab84e5953d5e5 /lib/sqfs/block_processor/serial.c
parent892066b0477186801d290953a9b994df353f8dbb (diff)
Cleanup: block processor: move init/cleanup functions into implemenations
Again, the generic init/cleanup functions do way too many things that are specific to the thread pool implementation. Thanks to the splitting up of the block processor, they also have become quite trivial. This commit moves those functions into their respective implementations, allowing even further simplificiation. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/block_processor/serial.c')
-rw-r--r--lib/sqfs/block_processor/serial.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/lib/sqfs/block_processor/serial.c b/lib/sqfs/block_processor/serial.c
index b1e1823..c9ee164 100644
--- a/lib/sqfs/block_processor/serial.c
+++ b/lib/sqfs/block_processor/serial.c
@@ -9,7 +9,11 @@
static void block_processor_destroy(sqfs_object_t *obj)
{
- block_processor_cleanup((sqfs_block_processor_t *)obj);
+ sqfs_block_processor_t *proc = (sqfs_block_processor_t *)obj;
+
+ free(proc->blk_current);
+ free(proc->frag_block);
+ free(proc);
}
sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
@@ -20,18 +24,17 @@ sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
sqfs_frag_table_t *tbl)
{
sqfs_block_processor_t *proc;
+ (void)num_workers; (void)max_backlog;
proc = alloc_flex(sizeof(*proc), 1, max_block_size);
-
if (proc == NULL)
return NULL;
- if (block_processor_init(proc, max_block_size, cmp, num_workers,
- max_backlog, wr, tbl)) {
- block_processor_cleanup(proc);
- return NULL;
- }
-
+ proc->max_block_size = max_block_size;
+ proc->cmp = cmp;
+ proc->frag_tbl = tbl;
+ proc->wr = wr;
+ proc->stats.size = sizeof(proc->stats);
((sqfs_object_t *)proc)->destroy = block_processor_destroy;
return proc;
}
@@ -80,18 +83,17 @@ int wait_completed(sqfs_block_processor_t *proc)
int sqfs_block_processor_finish(sqfs_block_processor_t *proc)
{
- if (proc->frag_block != NULL && proc->status == 0) {
- proc->status = block_processor_do_block(proc->frag_block,
- proc->cmp,
- proc->scratch,
- proc->max_block_size);
-
- if (proc->status == 0) {
- proc->status = process_completed_block(proc,
- proc->frag_block);
- }
- }
+ if (proc->frag_block == NULL || proc->status != 0)
+ goto out;
+
+ proc->status = block_processor_do_block(proc->frag_block, proc->cmp,
+ proc->scratch,
+ proc->max_block_size);
+ if (proc->status != 0)
+ goto out;
+ proc->status = process_completed_block(proc, proc->frag_block);
+out:
free(proc->frag_block);
proc->frag_block = NULL;
return proc->status;