add cleanup for function stats

This commit is contained in:
Patrick Lipka 2025-08-08 15:36:19 +02:00
parent 1d9318be0d
commit 8d5d145d0f
1 changed files with 18 additions and 1 deletions

View File

@ -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; i<stats->num_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)