small refactoring. memory leak fix
This commit is contained in:
@@ -472,7 +472,7 @@ void pst_function_fini(pst_function* fn)
|
||||
clear(fn);
|
||||
|
||||
if(fn->frame) {
|
||||
// use free here because it was allocate out of our control by libdw
|
||||
// use free here because it was allocated out of our control by libdw
|
||||
free(fn->frame);
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ static pst_function* last_function(pst_handler* h)
|
||||
bool pst_handler_handle_dwarf(pst_handler* h)
|
||||
{
|
||||
if(!h->functions.count) {
|
||||
if(!pst_handler_unwind(h)) {
|
||||
if(!pst_handler_unwind_simple(h)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,7 @@ const char* pst_print_simple(pst_handler* h)
|
||||
}
|
||||
|
||||
|
||||
bool pst_handler_unwind(pst_handler* h)
|
||||
bool pst_handler_unwind_simple(pst_handler* h)
|
||||
{
|
||||
void* caller = NULL; // pointer to the function which requested to unwind stack
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ pst_handler* pst_handler_new(ucontext_t* hctx);
|
||||
void pst_handler_fini(pst_handler* h);
|
||||
|
||||
bool pst_handler_handle_dwarf(pst_handler* h);
|
||||
bool pst_handler_unwind(pst_handler* h);
|
||||
bool pst_handler_unwind_simple(pst_handler* h);
|
||||
pst_function* pst_handler_next_function(pst_handler* h, pst_function* fn);
|
||||
|
||||
#endif /* __PST_DWARF_HANDLER_H__ */
|
||||
|
||||
+4
-1
@@ -22,15 +22,18 @@ pst_handler* pst_lib_init(ucontext_t* hctx, void* buff, uint32_t size)
|
||||
} else {
|
||||
pst_alloc_init_custom(&allocator, buff, size);
|
||||
}
|
||||
|
||||
pst_log_init_console(&logger);
|
||||
|
||||
pst_new(pst_handler, handler, hctx);
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
// deallocate libpst handler and library
|
||||
void pst_lib_fini(pst_handler* h)
|
||||
{
|
||||
pst_handler_fini(h);
|
||||
pst_free(h);
|
||||
|
||||
// global
|
||||
@@ -41,7 +44,7 @@ void pst_lib_fini(pst_handler* h)
|
||||
// save stack trace information to provided buffer in RAM
|
||||
int pst_unwind_simple(pst_handler* h)
|
||||
{
|
||||
return pst_handler_unwind(h);
|
||||
return pst_handler_unwind_simple(h);
|
||||
}
|
||||
|
||||
// save stack trace information to provided buffer in RAM
|
||||
|
||||
Reference in New Issue
Block a user