aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-05-23 05:03:26 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-05-23 05:03:26 +0200
commit0ffda020899f36e17e74a9cb2019066d753bddc2 (patch)
tree83254d2725803c731fe25a2a59aa849d33e60265
parentf2c487470dbfe3cf56f20b9899d5586ebcbefcc7 (diff)
block processor: don't zero initialize the block payload area
In the block processor, the payload area is only accessed up to the indicated size. Even the part that is accessed is initialized by copying data into the block before increasing the size, so there is no real point in zero-initializing hundres of kilobytes if not megabytes of payload area, especially since this is done in the locked, serial path of the block processor. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--lib/sqfs/block_processor/common.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/sqfs/block_processor/common.c b/lib/sqfs/block_processor/common.c
index 29e117d..50c0573 100644
--- a/lib/sqfs/block_processor/common.c
+++ b/lib/sqfs/block_processor/common.c
@@ -163,18 +163,19 @@ int process_completed_fragment(sqfs_block_processor_t *proc, sqfs_block_t *frag,
}
if (proc->frag_block == NULL) {
- size = sizeof(sqfs_block_t) + proc->max_block_size;
-
- err= sqfs_frag_table_append(proc->frag_tbl, 0, 0, &index);
+ err = sqfs_frag_table_append(proc->frag_tbl, 0, 0, &index);
if (err)
goto fail;
- proc->frag_block = calloc(1, size);
+ size = sizeof(sqfs_block_t) + proc->max_block_size;
+ proc->frag_block = malloc(size);
+
if (proc->frag_block == NULL) {
err = SQFS_ERROR_ALLOC;
goto fail;
}
+ memset(proc->frag_block, 0, sizeof(sqfs_block_t));
proc->frag_block->index = index;
proc->frag_block->flags = SQFS_BLK_FRAGMENT_BLOCK;
proc->stats.frag_block_count += 1;
@@ -268,10 +269,11 @@ int sqfs_block_processor_append(sqfs_block_processor_t *proc, const void *data,
while (size > 0) {
if (proc->blk_current == NULL) {
- new = alloc_flex(sizeof(*new), 1, proc->max_block_size);
+ new = malloc(sizeof(*new) + proc->max_block_size);
if (new == NULL)
return SQFS_ERROR_ALLOC;
+ memset(new, 0, sizeof(*new));
proc->blk_current = new;
proc->blk_current->flags = proc->blk_flags;
proc->blk_current->inode = proc->inode;