From a8dbfd5853e3a5f7f2a3ca817e96d9e0759061a2 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 8 Mar 2018 18:56:23 -0500 Subject: Make find_separate_debug_file* return std::string This patch makes the find_separate_debug_file* functions return std::string, which allows to get rid of some manual memory management and one cleanup. gdb/ChangeLog: * build-id.c (find_separate_debug_file_by_buildid): Return std::string. * build-id.h (find_separate_debug_file_by_buildid): Return std::string. * coffread.c (coff_symfile_read): Adjust to std::string. * elfread.c (elf_symfile_read): Adjust to std::string. * symfile.c (separate_debug_file_exists): Change parameter to std::string. (find_separate_debug_file): Return std::string. (find_separate_debug_file_by_debuglink): Return std::string. * symfile.h (find_separate_debug_file_by_debuglink): Return std::string. --- gdb/build-id.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gdb/build-id.c') diff --git a/gdb/build-id.c b/gdb/build-id.c index 57d98c9..a5d4e67 100644 --- a/gdb/build-id.c +++ b/gdb/build-id.c @@ -136,7 +136,7 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) /* See build-id.h. */ -char * +std::string find_separate_debug_file_by_buildid (struct objfile *objfile) { const struct bfd_build_id *build_id; @@ -157,7 +157,8 @@ find_separate_debug_file_by_buildid (struct objfile *objfile) warning (_("\"%s\": separate debug info file has no debug info"), bfd_get_filename (abfd.get ())); else if (abfd != NULL) - return xstrdup (bfd_get_filename (abfd.get ())); + return std::string (bfd_get_filename (abfd.get ())); } - return NULL; + + return std::string (); } -- cgit v1.1