add missing context management
This commit is contained in:
parent
24a26d8683
commit
8e31c88671
|
@ -0,0 +1,41 @@
|
||||||
|
#include "rvprof_internal.h"
|
||||||
|
|
||||||
|
void rvprof_context_cleanup(void){
|
||||||
|
if (!g_rvprof.initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate report
|
||||||
|
rvprof_output_generate_report();
|
||||||
|
|
||||||
|
// close output file
|
||||||
|
if (g_rvprof.output_file) {
|
||||||
|
fclose(g_rvprof.output_file);
|
||||||
|
g_rvprof.output_file = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// clean up dynamic arrays
|
||||||
|
region_array_cleanup(&g_rvprof.regions);
|
||||||
|
function_stats_array_cleanup(&g_rvprof.functions);
|
||||||
|
stack_info_array_cleanup(&g_rvprof.stacks);
|
||||||
|
symbol_array_cleanup(&g_rvprof.symbols);
|
||||||
|
|
||||||
|
// clean up configuration strings
|
||||||
|
if (g_rvprof.config.output_filename) {
|
||||||
|
rvprof_free(g_rvprof.config.output_filename,
|
||||||
|
strlen(g_rvprof.config.output_filename) + 1);
|
||||||
|
g_rvprof.config.output_filename = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_rvprof.config.program_name) {
|
||||||
|
rvprof_free(g_rvprof.config.program_name,
|
||||||
|
strlen(g_rvprof.config.program_name) + 1);
|
||||||
|
g_rvprof.config.program_name = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// reset state
|
||||||
|
g_rvprof.initialized = 0;
|
||||||
|
g_rvprof.auto_initialized = 0;
|
||||||
|
|
||||||
|
fprintf(stderr, "RVProf: Finalized\n");
|
||||||
|
}
|
|
@ -185,6 +185,8 @@ int rvprof_stats_get_or_create_stack_id(void);
|
||||||
void rvprof_stats_add_stack_id_to_function(int func_id, int stack_id);
|
void rvprof_stats_add_stack_id_to_function(int func_id, int stack_id);
|
||||||
void rvprof_stats_add_caller_to_function(int func_id, const char* caller);
|
void rvprof_stats_add_caller_to_function(int func_id, const char* caller);
|
||||||
|
|
||||||
|
// context management
|
||||||
|
void rvprof_context_cleanup(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue