This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA 4/5] Use std::vector in objfiles.c
- From: Tom Tromey <tom at tromey dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tom at tromey dot com>
- Date: Thu, 22 Sep 2016 11:50:55 -0600
- Subject: [RFA 4/5] Use std::vector in objfiles.c
- Authentication-results: sourceware.org; auth=none
- References: <1474566656-15389-1-git-send-email-tom@tromey.com>
This patch changes a spot in objfiles.c to use a std::vector, removing
a cleanup.
2016-09-22 Tom Tromey <tom@tromey.com>
* objfiles.c: Include <vector>.
(objfile_relocate): Use std::vector.
---
gdb/ChangeLog | 5 +++++
gdb/objfiles.c | 14 +++++++-------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 670406d..92e79c3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2016-09-22 Tom Tromey <tom@tromey.com>
+ * objfiles.c: Include <vector>.
+ (objfile_relocate): Use std::vector.
+
+2016-09-22 Tom Tromey <tom@tromey.com>
+
* rust-lang.c: Include <string> and <vector>.
(rust_evaluate_funcall): Use std::vector, std::string.
(rust_evaluate_subexp): Use std::string.
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index f022d10..bf594a1 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -53,6 +53,8 @@
#include "gdb_bfd.h"
#include "btrace.h"
+#include <vector>
+
/* Keep a registry of per-objfile data-pointers required by other GDB
modules. */
@@ -943,7 +945,7 @@ objfile_relocate (struct objfile *objfile,
debug_objfile = objfile_separate_debug_iterate (objfile, debug_objfile))
{
struct section_addr_info *objfile_addrs;
- struct section_offsets *new_debug_offsets;
+ std::vector<struct section_offsets> new_debug_offsets;
struct cleanup *my_cleanups;
objfile_addrs = build_section_addr_info_from_objfile (objfile);
@@ -956,15 +958,13 @@ objfile_relocate (struct objfile *objfile,
gdb_assert (debug_objfile->num_sections
== gdb_bfd_count_sections (debug_objfile->obfd));
- new_debug_offsets =
- ((struct section_offsets *)
- xmalloc (SIZEOF_N_SECTION_OFFSETS (debug_objfile->num_sections)));
- make_cleanup (xfree, new_debug_offsets);
- relative_addr_info_to_section_offsets (new_debug_offsets,
+ new_debug_offsets
+ .reserve (SIZEOF_N_SECTION_OFFSETS (debug_objfile->num_sections));
+ relative_addr_info_to_section_offsets (new_debug_offsets.data (),
debug_objfile->num_sections,
objfile_addrs);
- changed |= objfile_relocate1 (debug_objfile, new_debug_offsets);
+ changed |= objfile_relocate1 (debug_objfile, new_debug_offsets.data ());
do_cleanups (my_cleanups);
}
--
2.7.4