From 8d5d145d0ff4671e099614bca9195a760062569a Mon Sep 17 00:00:00 2001 From: Patrick Lipka Date: Fri, 8 Aug 2025 15:36:19 +0200 Subject: [PATCH] add cleanup for function stats --- src/rvprof_memory.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/rvprof_memory.c b/src/rvprof_memory.c index c1d71d3..0a52957 100644 --- a/src/rvprof_memory.c +++ b/src/rvprof_memory.c @@ -84,6 +84,23 @@ static void cleanup_symbol_entry(void* item){ symbol->name = NULL; } +static void cleanup_function_stats(void* item){ + function_stats_t* stats = (function_stats_t*)item; + if (stats->stack_ids) { + rvprof_free(stats->stack_ids, stats->max_stack_ids*sizeof(int)); + stats->stack_ids = NULL; + } + if (stats->callers) { + for (int i=0; inum_callers; i++){ + rvprof_free(stats->callers[i], strlen(stats->callers[i]+1)); + } + rvprof_free(stats->callers, stats->max_callers*sizeof(char*)); + stats->callers = NULL; + } +} + // acutal dynamic array implementations: IMPLEMENT_DYNAMIC_ARRAY(region_t, region, INITIAL_REGIONS, cleanup_region_entry) -IMPLEMENT_DYNAMIC_ARRAY(symbol_entry_t, symbol, INITIAL_SYMBOLS, cleanup_symbol_entry); +IMPLEMENT_DYNAMIC_ARRAY(symbol_entry_t, symbol, INITIAL_SYMBOLS, cleanup_symbol_entry) +IMPLEMENT_DYNAMIC_ARRAY(function_stats_t, function_stats, INITIAL_FUNCTIONS, cleanup_function_stats) +