diff options
Diffstat (limited to 'lib/sqfs/blk_proc/serial.c')
-rw-r--r-- | lib/sqfs/blk_proc/serial.c | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/lib/sqfs/blk_proc/serial.c b/lib/sqfs/blk_proc/serial.c index c7ec366..67272a3 100644 --- a/lib/sqfs/blk_proc/serial.c +++ b/lib/sqfs/blk_proc/serial.c @@ -15,32 +15,15 @@ sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size, sqfs_file_t *file) { 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; - proc->max_block_size = max_block_size; - proc->cmp = cmp; - proc->devblksz = devblksz; - proc->file = file; - proc->max_blocks = INIT_BLOCK_COUNT; - proc->frag_list_max = INIT_BLOCK_COUNT; - - proc->blocks = alloc_array(sizeof(proc->blocks[0]), proc->max_blocks); - if (proc->blocks == NULL) { - free(proc); - return NULL; - } - - proc->frag_list = alloc_array(sizeof(proc->frag_list[0]), - proc->frag_list_max); - if (proc->frag_list == NULL) { - free(proc->blocks); - free(proc); + if (block_processor_init(proc, max_block_size, cmp, num_workers, + max_backlog, devblksz, file)) { + block_processor_cleanup(proc); return NULL; } @@ -49,11 +32,7 @@ sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size, void sqfs_block_processor_destroy(sqfs_block_processor_t *proc) { - free(proc->frag_block); - free(proc->frag_list); - free(proc->fragments); - free(proc->blocks); - free(proc); + block_processor_cleanup(proc); } int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc, @@ -89,8 +68,9 @@ int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc, block = fragblk; } - proc->status = sqfs_block_process(block, proc->cmp, proc->scratch, - proc->max_block_size); + proc->status = block_processor_do_block(block, proc->cmp, + proc->scratch, + proc->max_block_size); if (proc->status == 0) proc->status = process_completed_block(proc, block); @@ -104,8 +84,9 @@ int sqfs_block_processor_finish(sqfs_block_processor_t *proc) if (proc->status != 0 || proc->frag_block == NULL) return proc->status; - proc->status = sqfs_block_process(proc->frag_block, proc->cmp, - proc->scratch, proc->max_block_size); + 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); |