Use class to manage BFD reference counts
[deliverable/binutils-gdb.git] / gdb / elfread.c
index eb175e65937447169e1cdb0d1b4b92e3f7742378..2ca10f8fdd7e9aedd432a2fcb2027b622ac16c77 100644 (file)
@@ -1265,21 +1265,18 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
           && objfile->separate_debug_objfile == NULL
           && objfile->separate_debug_objfile_backlink == NULL)
     {
-      char *debugfile;
-
-      debugfile = find_separate_debug_file_by_buildid (objfile);
+      gdb::unique_xmalloc_ptr<char> debugfile
+       (find_separate_debug_file_by_buildid (objfile));
 
       if (debugfile == NULL)
-       debugfile = find_separate_debug_file_by_debuglink (objfile);
+       debugfile.reset (find_separate_debug_file_by_debuglink (objfile));
 
-      if (debugfile)
+      if (debugfile != NULL)
        {
-         struct cleanup *cleanup = make_cleanup (xfree, debugfile);
-         bfd *abfd = symfile_bfd_open (debugfile);
+         gdb_bfd_ref_ptr abfd (symfile_bfd_open (debugfile.get ()));
 
-         make_cleanup_bfd_unref (abfd);
-         symbol_file_add_separate (abfd, debugfile, symfile_flags, objfile);
-         do_cleanups (cleanup);
+         symbol_file_add_separate (abfd.get (), debugfile.get (),
+                                   symfile_flags, objfile);
        }
     }
 }
This page took 0.032497 seconds and 4 git commands to generate.