diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-02-16 17:34:06 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-02-16 17:34:06 +0100 |
commit | 1c82a9f2fa98e68b68e6868298fba1830d91d1db (patch) | |
tree | 10d0943535cf2c52ac808234b810200d69202172 /lib/sqfs/block_processor/serial.c | |
parent | cab741413084e1f6b2bd9288273c7b14dfd4a8d7 (diff) |
block processor: move the internals to the respective implementations
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 | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/lib/sqfs/block_processor/serial.c b/lib/sqfs/block_processor/serial.c index e44ce17..2e00198 100644 --- a/lib/sqfs/block_processor/serial.c +++ b/lib/sqfs/block_processor/serial.c @@ -7,6 +7,12 @@ #define SQFS_BUILDING_DLL #include "internal.h" +typedef struct { + sqfs_block_processor_t base; + int status; + sqfs_u8 scratch[]; +} serial_block_processor_t; + static void block_processor_destroy(sqfs_object_t *obj) { sqfs_block_processor_t *proc = (sqfs_block_processor_t *)obj; @@ -23,71 +29,74 @@ sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size, sqfs_block_writer_t *wr, sqfs_frag_table_t *tbl) { - sqfs_block_processor_t *proc; + 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->max_block_size = max_block_size; - proc->cmp = cmp; - proc->frag_tbl = tbl; - proc->wr = wr; - proc->stats.size = sizeof(proc->stats); + 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 proc; + return (sqfs_block_processor_t *)proc; } 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; - if (proc->status != 0) + if (sproc->status != 0) goto done; - proc->status = block_processor_do_block(block, proc->cmp, - proc->scratch, - proc->max_block_size); - if (proc->status != 0) + sproc->status = block_processor_do_block(block, proc->cmp, + sproc->scratch, + proc->max_block_size); + if (sproc->status != 0) goto done; if (block->flags & SQFS_BLK_IS_FRAGMENT) { - proc->status = process_completed_fragment(proc, block, - &fragblk); + sproc->status = process_completed_fragment(proc, block, + &fragblk); if (fragblk == NULL) goto done; free(block); block = fragblk; - proc->status = block_processor_do_block(block, proc->cmp, - proc->scratch, - proc->max_block_size); - if (proc->status != 0) + sproc->status = block_processor_do_block(block, proc->cmp, + sproc->scratch, + proc->max_block_size); + if (sproc->status != 0) goto done; } - proc->status = process_completed_block(proc, block); + sproc->status = process_completed_block(proc, block); done: free(block); - return proc->status; + return sproc->status; } int sqfs_block_processor_finish(sqfs_block_processor_t *proc) { - if (proc->frag_block == NULL || proc->status != 0) + serial_block_processor_t *sproc = (serial_block_processor_t *)proc; + + if (proc->frag_block == NULL || sproc->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) + sproc->status = block_processor_do_block(proc->frag_block, proc->cmp, + sproc->scratch, + proc->max_block_size); + if (sproc->status != 0) goto out; - proc->status = process_completed_block(proc, proc->frag_block); + sproc->status = process_completed_block(proc, proc->frag_block); out: free(proc->frag_block); proc->frag_block = NULL; - return proc->status; + return sproc->status; } |