aboutsummaryrefslogtreecommitdiff
path: root/src/lib/data-stack.c
AgeCommit message (Collapse)AuthorLines
2021-10-07lib: t_get_bytes_available() - Move code inside DEBUG to avoid dead code warningTimo Sirainen-1/+1
2021-10-06lib: Fix data_stack_get_alloc_size() and data_stack_get_used_size()Timo Sirainen-2/+2
It only worked correctly if data stack hadn't been grown. This resulted in wrong numbers in the data_stack_grow event.
2021-09-22lib: Add most data_stack_grow event fields before checking if event is wantedTimo Sirainen-6/+14
This allows using e.g. "event=data_stack_grow and alloc_size > 32768" as an event filter.
2021-08-09lib: data-stack - Initialize alloc_count / alloc_bytesAki Tuomi-0/+4
This has only effect with devel checks enabled. Fixes counter values to show sensible data.
2021-08-09lib: data-stack - Allow errno changes when sending eventAki Tuomi-0/+8
2021-07-19lib: data-stack - t_try_realloc() - Add missing ↵Timo Sirainen-0/+1
data_stack_last_buffer_reset() call This fixes incorrect "buffer overflow" panics with DEBUG builds.
2021-07-19lib: data-stack - data_stack_last_buffer_reset(() - Add comments and an assertTimo Sirainen-0/+9
This clarifies how the function is expected to work.
2021-06-01lib: DEBUG: Fix potential crash in handling "Growing data stack" debug messageTimo Sirainen-2/+2
This could have only happened when data_stack_grow event was enabled and when --enable-devel-checks was used.
2021-05-24lib: data-stack - Keep the largest unused block in memory after allTimo Sirainen-10/+42
This reverts 2da21080dbbe50b4924ac0135c84babfb404dcce, but that alone doesn't produce working code so there are also some further fixups.
2021-05-04lib: data-stack - If frame doesn't change current block, no blocks need to ↵Timo Sirainen-8/+10
be freed This is a micro-optimization to t_pop() to avoid an extra if-check.
2021-05-04lib: data-stack - Use stack_block.left_lowwater only with DEBUGTimo Sirainen-4/+8
2021-05-04lib: Remove data_stack_set_clean_after_pop()Timo Sirainen-23/+13
2021-05-04lib: data-stack - Move frame memory allocation inside data stack blockTimo Sirainen-15/+16
2021-05-04lib: data-stack - Replace stack_frame_block with a single stack_frameTimo Sirainen-86/+56
This simplifies the code at the cost of more memory allocations. However, this will be fixed by the following commit.
2021-05-04lib: data-stack - Add data_stack_grow eventTimo Sirainen-12/+60
This is now always enabled, not just in debug builds.
2021-05-04lib: t_get_bytes_available() - Fix return value when current_block is almost ↵Timo Sirainen-6/+8
full
2021-05-04lib: data-stack - Add t_pop_pass_str() and T_END_PASS_STR[_IF]()Timo Sirainen-0/+15
This simplifies passing error strings out of stack frames. For example: const char *error; T_BEGIN { ... if (ret < 0) error = t_strdup_printf("foo() failed: %m"); } T_END_PASS_STR_IF(ret < 0, &error); // error is still valid
2021-05-04lib: Add data_stack_frame_contains()Timo Sirainen-0/+43
2021-05-04lib: Add data_stack_get_alloc_size()Timo Sirainen-0/+12
2021-05-04lib: Fix data_stack_get_used_size() to return correct sizeTimo Sirainen-3/+12
It only included the last allocated block's used size.
2021-05-04lib: data-stack - Don't set stack_block.next=NULL after mem_block_alloc() ↵Timo Sirainen-2/+0
already did it
2021-05-04lib: data-stack - mem_block_alloc() - Set stack_block.left to final value ↵Timo Sirainen-3/+1
immediately There's no need to first set it to 0 and then have the caller change it again.
2021-05-04lib: data-stack - Remove unused_frame_blocksTimo Sirainen-24/+6
It's not that expensive to keep allocating them as needed, and it's a potential waste of memory to keep them around.
2021-05-04lib: data-stack - Don't keep largest unused block in memoryTimo Sirainen-20/+6
It's not that expensive to allocate it again, but it might be expensive to keep allocated a block that became huge due to a bug. The huge block could be just wasting memory without ever being used again.
2021-05-04lib: data-stack - Rename variables in clean_after_pop handlingTimo Sirainen-6/+6
These new variables make more sense than the old ones.
2021-05-04lib: data-stack - Rename lowwater to left_lowwaterTimo Sirainen-8/+12
This describes its behavior better. Also add a comment explaining what exactly it is.
2021-05-04lib: data-stack - Rename block_space_used[] to block_space_left[]Timo Sirainen-5/+8
This describes its behavior better. Also add a comment explaining what exactly it is.
2021-05-04lib: data-stack - Use INITIAL_STACK_SIZE without growing it to nearest powerTimo Sirainen-1/+3
2021-05-04global: Never use t_push(NULL)Timo Sirainen-1/+3
A non-NULL name is expected by the debug logging.
2020-11-23lib: Add data_stack_get_used_size()Timo Sirainen-0/+10
Mainly for debugging purposes.
2020-10-22global: Disable undefined behaviour sanitization for select locationsAki Tuomi-1/+2
2020-03-19global: use %zu directly instead of PRIuSIZE_TJosef 'Jeff' Sipek-4/+4
2019-05-13lib: data-stack - Make STACK_BLOCK_DATA() behavior clearerTimo Sirainen-2/+2
Otherwise scan-build thinks that it's pointing outside valid memory in the struct and gives an error: "Memory set function accesses out-of-bound array element"
2018-01-01Updated copyright notices to include the year 2018.Stephan Bosch-1/+1
2017-12-25lib/data-stack - in panic scenarios, use the panic memory bufferPhil Carmody-4/+4
Signed-off-by: Phil Carmody <phil@dovecot.fi>
2017-12-25lib/datastack - remove useless thingPhil Carmody-1/+0
It was useless. Signed-off-by: Phil Carmody <phil@dovecot.fi>
2017-11-27lib: Fix logging panic message if data stack canary corruption is detectedTimo Sirainen-8/+23
The previous code just recursed into the same canary corruption check and didn't end up logging anything.
2017-10-06global: Use PRI* macros and %zu instead of castingMartti Rannanjärvi-1/+1
2017-07-07lib: remove support for Boehm GCJosef 'Jeff' Sipek-20/+0
There were several issues with our usage of Boehm GC: - it didn't help with memory fragmentation - it is not very efficient - it was rarely enabled & used Proper use of a GC would involve radical changes to how we write code and cause portability issues. We can get most of the benefits of a GC with data stacks and alloc-only memory pools.
2017-01-01Updated copyright notices to include the year 2017.Stephan Bosch-1/+1
2016-12-16global: Make sure *_malloc() calculations won't cause integer overflows.Timo Sirainen-1/+3
2016-11-02data-stack: t_push should always keep track of the markerJosef 'Jeff' Sipek-4/+2
Instead of only keeping track of it on DEBUG builds, t_push should always keep the marker around. This will help diagnosing issues on non-debug builds.
2016-10-06lib-test: Fixed assert-crash in test_exit() with --enable-static-checkerTimo Sirainen-3/+9
Fixes: Panic: Missing t_pop() call
2016-09-08lib: Allow static analyzers to check for t_pop() leaks.Timo Sirainen-6/+20
They should be able to detect the missing free() call from code paths missing a t_pop().
2016-09-02lib: If DEBUG is enabled, use a pointer type for data_stack_frame_tTimo Sirainen-1/+7
This allows telling static analyzers to treat t_push() and t_pop() similarly to malloc()/free() and check for leaks.
2016-09-02lib: Changed t_pop() API to make it a bit more like free()Timo Sirainen-13/+9
2016-09-02lib: Created data_stack_frame_t type for data_stack_frameTimo Sirainen-6/+6
2016-09-02lib: Small code cleanup to data-stack - use explicit data_stack_initializedTimo Sirainen-3/+5
This will make it easier to change data_stack_frame's type.
2016-09-02lib: Minor t_push() optimization - use unlikely()Timo Sirainen-1/+1
2016-08-01lib,lib-test: i_warning to i_debug on alloc growing messagesMartti Rannanjärvi-2/+2