From d721ba37d8995b9c11a0b8eef0f4d2dc022f85aa Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 27 Mar 2017 11:56:28 +0100 Subject: gdb: Make ldirname return a std::string Eliminates several uses of cleanups. Tested on x86_64 Fedora 23 with Python 2 and 3. gdb/ChangeLog 2017-03-27 Pedro Alves * dwarf2read.c (struct file_and_directory): New. (dwarf2_get_dwz_file): Adjust to use std::string. (dw2_get_file_names_reader): Adjust to use file_and_directory. (find_file_and_directory): Adjust to return a file_and_directory object. (read_file_scope): Adjust to use file_and_directory. Remove make_cleanup/do_cleanups calls. (open_and_init_dwp_file): Adjust to use std::string. Remove make_cleanup/do_cleanups calls. * python/python.c (do_start_initialization): Adjust to ldirname returning a std::string. * utils.c (ldirname): Now returns a std::string. * utils.h (ldirname): Change return type to std::string. * xml-syscall.c (xml_init_syscalls_info): Adjust to ldirname returning a std::string. * xml-tdesc.c (file_read_description_xml): Likewise. --- gdb/xml-tdesc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'gdb/xml-tdesc.c') diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c index 1677659..effe652 100644 --- a/gdb/xml-tdesc.c +++ b/gdb/xml-tdesc.c @@ -694,7 +694,6 @@ file_read_description_xml (const char *filename) struct target_desc *tdesc; char *tdesc_str; struct cleanup *back_to; - char *dirname; tdesc_str = xml_fetch_content_from_file (filename, NULL); if (tdesc_str == NULL) @@ -705,11 +704,8 @@ file_read_description_xml (const char *filename) back_to = make_cleanup (xfree, tdesc_str); - dirname = ldirname (filename); - if (dirname != NULL) - make_cleanup (xfree, dirname); - - tdesc = tdesc_parse_xml (tdesc_str, xml_fetch_content_from_file, dirname); + tdesc = tdesc_parse_xml (tdesc_str, xml_fetch_content_from_file, + (void *) ldirname (filename).c_str ()); do_cleanups (back_to); return tdesc; -- cgit v1.1