aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfs/block_processor/serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqfs/block_processor/serial.c')
-rw-r--r--lib/sqfs/block_processor/serial.c75
1 files changed, 38 insertions, 37 deletions
diff --git a/lib/sqfs/block_processor/serial.c b/lib/sqfs/block_processor/serial.c
index 54edda1..9768a7f 100644
--- a/lib/sqfs/block_processor/serial.c
+++ b/lib/sqfs/block_processor/serial.c
@@ -39,30 +39,8 @@ static void block_processor_destroy(sqfs_object_t *obj)
free(proc);
}
-sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
- sqfs_compressor_t *cmp,
- unsigned int num_workers,
- size_t max_backlog,
- sqfs_block_writer_t *wr,
- sqfs_frag_table_t *tbl)
-{
- serial_block_processor_t *proc;
- (void)num_workers; (void)max_backlog;
-
- proc = alloc_flex(sizeof(*proc), 1, max_block_size);
- if (proc == NULL)
- return NULL;
-
- proc->base.max_block_size = max_block_size;
- proc->base.cmp = cmp;
- proc->base.frag_tbl = tbl;
- proc->base.wr = wr;
- proc->base.stats.size = sizeof(proc->base.stats);
- ((sqfs_object_t *)proc)->destroy = block_processor_destroy;
- return (sqfs_block_processor_t *)proc;
-}
-
-int append_to_work_queue(sqfs_block_processor_t *proc, sqfs_block_t *block)
+static int append_to_work_queue(sqfs_block_processor_t *proc,
+ sqfs_block_t *block)
{
serial_block_processor_t *sproc = (serial_block_processor_t *)proc;
sqfs_block_t *fragblk = NULL;
@@ -70,27 +48,26 @@ int append_to_work_queue(sqfs_block_processor_t *proc, sqfs_block_t *block)
if (sproc->status != 0)
goto fail;
- sproc->status = block_processor_do_block(block, proc->cmp,
- sproc->scratch,
- proc->max_block_size);
+ sproc->status = proc->process_block(block, proc->cmp, sproc->scratch,
+ proc->max_block_size);
if (sproc->status != 0)
goto fail;
if (block->flags & SQFS_BLK_IS_FRAGMENT) {
- sproc->status = process_completed_fragment(proc, block,
- &fragblk);
+ sproc->status = proc->process_completed_fragment(proc, block,
+ &fragblk);
if (fragblk == NULL)
return sproc->status;
block = fragblk;
- sproc->status = block_processor_do_block(block, proc->cmp,
- sproc->scratch,
- proc->max_block_size);
+ sproc->status = proc->process_block(block, proc->cmp,
+ sproc->scratch,
+ proc->max_block_size);
if (sproc->status != 0)
goto fail;
}
- sproc->status = process_completed_block(proc, block);
+ sproc->status = proc->process_completed_block(proc, block);
return sproc->status;
fail:
free_block_list(block->frag_list);
@@ -98,6 +75,30 @@ fail:
return sproc->status;
}
+sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
+ sqfs_compressor_t *cmp,
+ unsigned int num_workers,
+ size_t max_backlog,
+ sqfs_block_writer_t *wr,
+ sqfs_frag_table_t *tbl)
+{
+ serial_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->base, max_block_size, cmp, wr, tbl)) {
+ free(proc);
+ return NULL;
+ }
+
+ proc->base.append_to_work_queue = append_to_work_queue;
+ ((sqfs_object_t *)proc)->destroy = block_processor_destroy;
+ return (sqfs_block_processor_t *)proc;
+}
+
int sqfs_block_processor_sync(sqfs_block_processor_t *proc)
{
return ((serial_block_processor_t *)proc)->status;
@@ -110,13 +111,13 @@ int sqfs_block_processor_finish(sqfs_block_processor_t *proc)
if (proc->frag_block == NULL || sproc->status != 0)
goto fail;
- sproc->status = block_processor_do_block(proc->frag_block, proc->cmp,
- sproc->scratch,
- proc->max_block_size);
+ sproc->status = proc->process_block(proc->frag_block, proc->cmp,
+ sproc->scratch,
+ proc->max_block_size);
if (sproc->status != 0)
goto fail;
- sproc->status = process_completed_block(proc, proc->frag_block);
+ sproc->status = proc->process_completed_block(proc, proc->frag_block);
proc->frag_block = NULL;
return sproc->status;
fail: