diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-05-29 03:38:10 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-05-29 03:40:12 +0200 |
commit | cada7ca7d9386e68c38fc504c01bd2cac33dac44 (patch) | |
tree | 3fa6272a42a0504263d350ba82638579ad6d25ed /lib/sqfs/block_processor/serial.c | |
parent | 4b20b555bd9813ce85cacf78f0c194fa66ad5172 (diff) |
Block processor: turn internal functions into interface entry points
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.c | 75 |
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: |