]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: data-stack - mem_block_alloc() - Set stack_block.left to final value immediately
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 31 Mar 2021 09:51:34 +0000 (12:51 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 4 May 2021 07:02:35 +0000 (07:02 +0000)
There's no need to first set it to 0 and then have the caller change it
again.

src/lib/data-stack.c

index a1bd6bccfbe70f280c60a0abd13581e237e245aa..895a6950f4ce60fec05b5c55dd878a265a0eb102 100644 (file)
@@ -354,7 +354,7 @@ static struct stack_block *mem_block_alloc(size_t min_size)
                        alloc_size + SIZEOF_MEMBLOCK);
        }
        block->size = alloc_size;
-       block->left = 0;
+       block->left = block->size;
        block->left_lowwater = block->size;
        block->next = NULL;
        block->canary = BLOCK_CANARY;
@@ -406,7 +406,6 @@ static void *t_malloc_real(size_t size, bool permanent)
                warn = TRUE;
 #endif
 
-               block->left = block->size;
                block->next = NULL;
                current_block->next = block;
                current_block = block;
@@ -600,7 +599,6 @@ void data_stack_init(void)
        outofmem_area.block.canary = BLOCK_CANARY;
 
        current_block = mem_block_alloc(INITIAL_STACK_SIZE);
-       current_block->left = current_block->size;
        current_block->next = NULL;
 
        current_frame_block = NULL;