summaryrefslogtreecommitdiff
path: root/lib/sqfs/blk_proc/fragtbl.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-24 03:18:07 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-24 03:18:07 +0200
commit035cbdfe1bc5aea16cbcada5e3c00ecf5ac08c96 (patch)
tree91a3a86c8589cec7d2ebb70e2fdfb4e9f05cc3c5 /lib/sqfs/blk_proc/fragtbl.c
parent94b507f2c1c7244493473a0a6673d726a6fe9cf5 (diff)
Breake some of the helper functions out of process_block.c
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/blk_proc/fragtbl.c')
-rw-r--r--lib/sqfs/blk_proc/fragtbl.c22
1 files changed, 22 insertions, 0 deletions
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;
+}