summaryrefslogtreecommitdiff
path: root/lib/sqfs/data_writer.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-25 19:16:11 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-25 19:16:11 +0200
commitf49fe3bbf0d52e2afcc1ace8c1f48dee9349d4f8 (patch)
tree41e55971f8f1052c0457332dbf5718f7b7a9c661 /lib/sqfs/data_writer.c
parent798abd9eaf3c9e8aa83c4dca28cdd44890253efe (diff)
Cleanup sqfs_write_table
This commit attempts to make the generic table writer more readable. A few changes are made, including heap allocation of the block list. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/data_writer.c')
-rw-r--r--lib/sqfs/data_writer.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/sqfs/data_writer.c b/lib/sqfs/data_writer.c
index 74701fd..ae8257c 100644
--- a/lib/sqfs/data_writer.c
+++ b/lib/sqfs/data_writer.c
@@ -295,6 +295,8 @@ void data_writer_destroy(data_writer_t *data)
int data_writer_write_fragment_table(data_writer_t *data)
{
uint64_t start;
+ size_t size;
+ int ret;
if (data->num_fragments == 0) {
data->super->fragment_entry_count = 0;
@@ -302,14 +304,13 @@ int data_writer_write_fragment_table(data_writer_t *data)
return 0;
}
- data->super->fragment_entry_count = data->num_fragments;
-
- if (sqfs_write_table(data->outfd, data->super, data->fragments,
- sizeof(data->fragments[0]), data->num_fragments,
- &start, data->cmp)) {
+ size = sizeof(data->fragments[0]) * data->num_fragments;
+ ret = sqfs_write_table(data->outfd, data->super, data->cmp,
+ data->fragments, size, &start);
+ if (ret)
return -1;
- }
+ data->super->fragment_entry_count = data->num_fragments;
data->super->fragment_table_start = start;
return 0;
}