diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-01-24 16:15:07 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-01-24 16:15:55 +0100 |
commit | 7fcbe8e10ac062ac449b6d1bbcf22bfd6529d66f (patch) | |
tree | ad833deaf430fac6acbd6ad66bfc0639f1540048 /lib/sqfs/data_writer/fragment.c | |
parent | f7c29ffee7fdd61470fd879cfae470534423c0c7 (diff) |
Cleanup: use fragment table primitive in data writer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/data_writer/fragment.c')
-rw-r--r-- | lib/sqfs/data_writer/fragment.c | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/lib/sqfs/data_writer/fragment.c b/lib/sqfs/data_writer/fragment.c index 1957983..70679c9 100644 --- a/lib/sqfs/data_writer/fragment.c +++ b/lib/sqfs/data_writer/fragment.c @@ -7,27 +7,6 @@ #define SQFS_BUILDING_DLL #include "internal.h" -static int grow_fragment_table(sqfs_data_writer_t *proc) -{ - size_t newsz; - void *new; - - if (proc->num_fragments >= proc->max_fragments) { - newsz = proc->max_fragments ? proc->max_fragments * 2 : 16; - - new = realloc(proc->fragments, - sizeof(proc->fragments[0]) * newsz); - - if (new == NULL) - return SQFS_ERROR_ALLOC; - - proc->max_fragments = newsz; - proc->fragments = new; - } - - return 0; -} - static int grow_deduplication_list(sqfs_data_writer_t *proc) { size_t new_sz; @@ -80,6 +59,7 @@ int process_completed_fragment(sqfs_data_writer_t *proc, sqfs_block_t *frag, sqfs_block_t **blk_out) { sqfs_u64 hash; + sqfs_u32 index; size_t i, size; int err; @@ -102,7 +82,7 @@ int process_completed_fragment(sqfs_data_writer_t *proc, sqfs_block_t *frag, if (proc->frag_block == NULL) { size = sizeof(sqfs_block_t) + proc->max_block_size; - err = grow_fragment_table(proc); + err= sqfs_frag_table_append(proc->frag_tbl, 0, 0, &index); if (err) goto fail; @@ -112,7 +92,7 @@ int process_completed_fragment(sqfs_data_writer_t *proc, sqfs_block_t *frag, goto fail; } - proc->frag_block->index = proc->num_fragments++; + proc->frag_block->index = index; proc->frag_block->flags = SQFS_BLK_FRAGMENT_BLOCK; } |