From: Omar Sandoval Date: Mon, 7 Oct 2019 09:05:35 +0000 (-0700) Subject: libdwfl: don't bother freeing frames outside of dwfl_thread_getframes X-Git-Tag: elfutils-0.178~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f447ef7f0c5000e88d11312c06df9d5021d4ecd;p=thirdparty%2Felfutils.git 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 --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 04a39637e..f4a3cad9a 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,9 @@ +2019-10-07 Omar Sandoval + + * dwfl_frame.c (dwfl_getthreads): Get rid of unnecessary + thread_free_all_states calls. + (getthread): Ditto. + 2019-08-12 Mark Wielaard * 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 881f735af..20bdbd9b2 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;