From 0ffda020899f36e17e74a9cb2019066d753bddc2 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 23 May 2020 05:03:26 +0200 Subject: 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 --- lib/sqfs/block_processor/common.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lib/sqfs') 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; -- cgit v1.2.3