From: Timm Bäder <tbae...@redhat.com> Signed-off-by: Timm Bäder <tbae...@redhat.com> --- libdwfl/dwfl_segment_report_module.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 848c3bec..c55168ed 100644 --- a/libdwfl/dwfl_segment_report_module.c +++ b/libdwfl/dwfl_segment_report_module.c @@ -232,6 +232,16 @@ invalid_elf (Elf *elf, bool disk_file_has_build_id, return false; } +static inline void +finish_portion (Dwfl *dwfl, + Dwfl_Memory_Callback *memory_callback, + void *memory_callback_arg, + void **data, size_t *data_size) +{ + if (*data_size != 0 && *data != NULL) + (*memory_callback) (dwfl, -1, data, data_size, 0, 0, memory_callback_arg); +} + int dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, Dwfl_Memory_Callback *memory_callback, @@ -297,12 +307,6 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, return false; } - inline void finish_portion (void **data, size_t *data_size) - { - if (*data_size != 0 && *data != NULL) - (*memory_callback) (dwfl, -1, data, data_size, 0, 0, memory_callback_arg); - } - /* Extract the information we need from the file header. */ const unsigned char *e_ident; unsigned char ei_class; @@ -509,7 +513,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, done: if (notes != data) free (notes); - finish_portion (&data, &data_size); + finish_portion (dwfl, memory_callback, memory_callback_arg, &data, &data_size); } /* Consider each of the program headers we've read from the image. */ @@ -606,7 +610,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, p64[i].p_align); } - finish_portion (&ph_buffer, &ph_buffer_size); + finish_portion (dwfl, memory_callback, memory_callback_arg, &ph_buffer, &ph_buffer_size); /* We must have seen the segment covering offset 0, or else the ELF header we read at START was not produced by these program headers. */ @@ -798,7 +802,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, } free (dyns); } - finish_portion (&dyn_data, &dyn_data_size); + finish_portion (dwfl, memory_callback, memory_callback_arg, &dyn_data, &dyn_data_size); /* We'll use the name passed in or a stupid default if not DT_SONAME. */ if (name == NULL) @@ -859,7 +863,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, /* At this point we do not need BUILD_ID or NAME any more. They have been copied. */ free (build_id); - finish_portion (&soname, &soname_size); + finish_portion (dwfl, memory_callback, memory_callback_arg, &soname, &soname_size); if (unlikely (mod == NULL)) { -- 2.26.2