This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Use gdb::unique_ptr in elf_read_minimal_symbols
- From: Tom Tromey <tromey at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 21 Oct 2016 20:29:50 -0000
- Subject: [binutils-gdb] Use gdb::unique_ptr in elf_read_minimal_symbols
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d1e4a624699fd734b3b6e87fb79a4da71c182dfd
commit d1e4a624699fd734b3b6e87fb79a4da71c182dfd
Author: Tom Tromey <tom@tromey.com>
Date: Sat Sep 24 21:31:36 2016 -0600
Use gdb::unique_ptr in elf_read_minimal_symbols
This changes elf_read_minimal_symbols to use gdb::unique_ptr rather
than an explicit allocation. This removes a cleanup.
2016-10-21 Tom Tromey <tom@tromey.com>
* elfread.c (elf_read_minimal_symbols): Use gdb::unique_ptr.
Diff:
---
gdb/ChangeLog | 4 ++++
gdb/elfread.c | 11 +++--------
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e28e774..5c87f32 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2016-10-21 Tom Tromey <tom@tromey.com>
+ * elfread.c (elf_read_minimal_symbols): Use gdb::unique_ptr.
+
+2016-10-21 Tom Tromey <tom@tromey.com>
+
* cli/cli-dump.c (dump_memory_to_file): Use gdb::unique_ptr.
(restore_binary_file): Likewise.
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 56fac28..485e55d 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1024,7 +1024,6 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
const struct elfinfo *ei)
{
bfd *synth_abfd, *abfd = objfile->obfd;
- struct cleanup *back_to;
long symcount = 0, dynsymcount = 0, synthcount, storage_needed;
asymbol **symbol_table = NULL, **dyn_symbol_table = NULL;
asymbol *synthsyms;
@@ -1053,7 +1052,6 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
}
minimal_symbol_reader reader (objfile);
- back_to = make_cleanup (null_cleanup, NULL);
/* Allocate struct to keep track of the symfile. */
dbx = XCNEW (struct dbx_symfile_info);
@@ -1135,16 +1133,14 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
&synthsyms);
if (synthcount > 0)
{
- asymbol **synth_symbol_table;
long i;
- make_cleanup (xfree, synthsyms);
- synth_symbol_table = XNEWVEC (asymbol *, synthcount);
+ gdb::unique_ptr<asymbol *[]>
+ synth_symbol_table (new asymbol *[synthcount]);
for (i = 0; i < synthcount; i++)
synth_symbol_table[i] = synthsyms + i;
- make_cleanup (xfree, synth_symbol_table);
elf_symtab_read (reader, objfile, ST_SYNTHETIC, synthcount,
- synth_symbol_table, 1);
+ synth_symbol_table.get (), 1);
}
/* Install any minimal symbols that have been collected as the current
@@ -1154,7 +1150,6 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
which will do this. */
reader.install ();
- do_cleanups (back_to);
if (symtab_create_debug)
fprintf_unfiltered (gdb_stdlog, "Done reading minimal symbols.\n");