From 035cbdfe1bc5aea16cbcada5e3c00ecf5ac08c96 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 24 Sep 2019 03:18:07 +0200 Subject: Breake some of the helper functions out of process_block.c Signed-off-by: David Oberhollenzer --- lib/sqfs/blk_proc/fragtbl.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lib/sqfs/blk_proc/fragtbl.c') diff --git a/lib/sqfs/blk_proc/fragtbl.c b/lib/sqfs/blk_proc/fragtbl.c index 81baf09..3f6c644 100644 --- a/lib/sqfs/blk_proc/fragtbl.c +++ b/lib/sqfs/blk_proc/fragtbl.c @@ -34,3 +34,25 @@ int sqfs_block_processor_write_fragment_table(sqfs_block_processor_t *proc, super->fragment_table_start = start; return 0; } + +int grow_fragment_table(sqfs_block_processor_t *proc, size_t index) +{ + size_t newsz; + void *new; + + if (index < proc->max_fragments) + return 0; + + do { + newsz = proc->max_fragments ? proc->max_fragments * 2 : 16; + } while (index >= newsz); + + 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; +} -- cgit v1.2.3