Remove some cleanups from solib.c
authorTom Tromey <tom@tromey.com>
Fri, 10 Nov 2017 20:48:48 +0000 (13:48 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 19 Mar 2018 03:50:00 +0000 (21:50 -0600)
This removes some cleanups from solib.c, replacing them with
gdb::def_vector.

Regression tested by the buildbot.

gdb/ChangeLog
2018-03-18  Tom Tromey  <tom@tromey.com>

* solib.c (gdb_bfd_lookup_symbol_from_symtab): Use
gdb::def_vector.
(bfd_lookup_symbol_from_dyn_symtab): Likewise.

gdb/ChangeLog
gdb/solib.c

index 4ab82d82a413235d68f6d07ebc109eb47a6ed8de..634a414eaceb9ce6ab070810fae6e9d45d63e8dd 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-18  Tom Tromey  <tom@tromey.com>
+
+       * solib.c (gdb_bfd_lookup_symbol_from_symtab): Use
+       gdb::def_vector.
+       (bfd_lookup_symbol_from_dyn_symtab): Likewise.
+
 2018-03-17  Tom Tromey  <tom@tromey.com>
 
        * auto-load.c (auto_load_objfile_script_1): Use std::string.
index f9a31bca196757f83a6503e1fa3ad20cf008a7d2..77c1268449ed8c66ff779c87c49337fd1403f8f8 100644 (file)
@@ -1474,8 +1474,8 @@ gdb_bfd_lookup_symbol_from_symtab (bfd *abfd,
     {
       unsigned int i;
 
-      asymbol **symbol_table = (asymbol **) xmalloc (storage_needed);
-      struct cleanup *back_to = make_cleanup (xfree, symbol_table);
+      gdb::def_vector<asymbol *> storage (storage_needed / sizeof (asymbol *));
+      asymbol **symbol_table = storage.data ();
       unsigned int number_of_symbols =
        bfd_canonicalize_symtab (abfd, symbol_table);
 
@@ -1510,7 +1510,6 @@ gdb_bfd_lookup_symbol_from_symtab (bfd *abfd,
              break;
            }
        }
-      do_cleanups (back_to);
     }
 
   return symaddr;
@@ -1533,8 +1532,8 @@ bfd_lookup_symbol_from_dyn_symtab (bfd *abfd,
   if (storage_needed > 0)
     {
       unsigned int i;
-      asymbol **symbol_table = (asymbol **) xmalloc (storage_needed);
-      struct cleanup *back_to = make_cleanup (xfree, symbol_table);
+      gdb::def_vector<asymbol *> storage (storage_needed / sizeof (asymbol *));
+      asymbol **symbol_table = storage.data ();
       unsigned int number_of_symbols =
        bfd_canonicalize_dynamic_symtab (abfd, symbol_table);
 
@@ -1549,7 +1548,6 @@ bfd_lookup_symbol_from_dyn_symtab (bfd *abfd,
              break;
            }
        }
-      do_cleanups (back_to);
     }
   return symaddr;
 }