Use std::vector in objfiles.c
authorTom Tromey <tom@tromey.com>
Thu, 22 Sep 2016 14:33:13 +0000 (08:33 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 23 Sep 2016 17:37:08 +0000 (11:37 -0600)
This patch changes a spot in objfiles.c to use a std::vector, removing
a cleanup.

2016-09-23  Tom Tromey  <tom@tromey.com>

* objfiles.c: Include <vector>.
(objfile_relocate): Use std::vector.

gdb/ChangeLog
gdb/objfiles.c

index ab90503d35fdf498dfbc04972863389c0925f53c..161da29ed500ddd520507d90661fdbb76aaa866f 100644 (file)
@@ -1,3 +1,8 @@
+2016-09-23  Tom Tromey  <tom@tromey.com>
+
+       * objfiles.c: Include <vector>.
+       (objfile_relocate): Use std::vector.
+
 2016-09-23  Tom Tromey  <tom@tromey.com>
 
        * rust-lang.c: Include <string> and <vector>.
index f022d104fe04b0f3ac985172eb10b5968fea13a3..71f771d8e21b312b4e2f8ce9fe93d9518138b4bb 100644 (file)
@@ -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,6 @@ 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;
       struct cleanup *my_cleanups;
 
       objfile_addrs = build_section_addr_info_from_objfile (objfile);
@@ -956,15 +957,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,
+      std::vector<struct section_offsets>
+       new_debug_offsets (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);
     }
This page took 0.030571 seconds and 4 git commands to generate.