diff options
author | Omar Sandoval <osandov@fb.com> | 2019-10-07 02:05:35 -0700 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2019-10-29 17:48:05 +0100 |
commit | 6f447ef7f0c5000e88d11312c06df9d5021d4ecd (patch) | |
tree | 6c40b58f0a7aeef1e28588bb34420bdc33a4befe | |
parent | b2dddd3389a8005a7e93bc21b2932156899e1aac (diff) |
libdwfl: don't bother freeing frames outside of dwfl_thread_getframes
dwfl_thread_getframes always frees the state before returning, so
dwfl_getthreads and getthread don't need to do it. The only place
we allocate the state is from dwfl_thread_getframes and we always
free it before returning from that function.
Signed-off-by: Omar Sandoval <osandov@fb.com>
-rw-r--r-- | libdwfl/ChangeLog | 6 | ||||
-rw-r--r-- | libdwfl/dwfl_frame.c | 18 |
2 files changed, 9 insertions, 15 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 04a39637..f4a3cad9 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,9 @@ +2019-10-07 Omar Sandoval <osandov@fb.com> + + * dwfl_frame.c (dwfl_getthreads): Get rid of unnecessary + thread_free_all_states calls. + (getthread): Ditto. + 2019-08-12 Mark Wielaard <mark@klomp.org> * gzip.c (open_stream): Return DWFL_E_ERRNO on bad file operation. diff --git a/libdwfl/dwfl_frame.c b/libdwfl/dwfl_frame.c index 881f735a..20bdbd9b 100644 --- a/libdwfl/dwfl_frame.c +++ b/libdwfl/dwfl_frame.c @@ -279,24 +279,15 @@ dwfl_getthreads (Dwfl *dwfl, int (*callback) (Dwfl_Thread *thread, void *arg), process->callbacks_arg, &thread.callbacks_arg); if (thread.tid < 0) - { - Dwfl_Error saved_errno = dwfl_errno (); - thread_free_all_states (&thread); - __libdwfl_seterrno (saved_errno); - return -1; - } + return -1; if (thread.tid == 0) { - thread_free_all_states (&thread); __libdwfl_seterrno (DWFL_E_NOERROR); return 0; } int err = callback (&thread, arg); if (err != DWARF_CB_OK) - { - thread_free_all_states (&thread); - return err; - } + return err; assert (thread.unwound == NULL); } /* NOTREACHED */ @@ -356,11 +347,8 @@ getthread (Dwfl *dwfl, pid_t tid, if (process->callbacks->get_thread (dwfl, tid, process->callbacks_arg, &thread.callbacks_arg)) { - int err; thread.tid = tid; - err = callback (&thread, arg); - thread_free_all_states (&thread); - return err; + return callback (&thread, arg); } return -1; |