This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Use unique_xmalloc_ptr in solib-aix.c
- From: Tom Tromey <tromey at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 18 Jun 2018 19:34:01 -0000
- Subject: [binutils-gdb] Use unique_xmalloc_ptr in solib-aix.c
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f709fabb61246953e68ae46478a3b269c0615fce
commit f709fabb61246953e68ae46478a3b269c0615fce
Author: Tom Tromey <tom@tromey.com>
Date: Sun May 27 09:33:24 2018 -0600
Use unique_xmalloc_ptr in solib-aix.c
This removes a cleanup from solib-aix.c via unique_xmalloc_ptr.
gdb/ChangeLog
2018-06-18 Tom Tromey <tom@tromey.com>
* solib-aix.c (solib_aix_get_section_offsets): Return
unique_xmalloc_ptr.
(solib_aix_solib_create_inferior_hook): Update.
Diff:
---
gdb/ChangeLog | 6 ++++++
gdb/solib-aix.c | 12 +++++-------
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c6112d2..4fc6cf5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2018-06-18 Tom Tromey <tom@tromey.com>
+ * solib-aix.c (solib_aix_get_section_offsets): Return
+ unique_xmalloc_ptr.
+ (solib_aix_solib_create_inferior_hook): Update.
+
+2018-06-18 Tom Tromey <tom@tromey.com>
+
* solib-darwin.c (darwin_current_sos): Use unique_xmalloc_ptr.
2018-06-18 Tom Tromey <tom@tromey.com>
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index 6e5b8b1..8e8901e 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -439,14 +439,14 @@ solib_aix_clear_solib (void)
The resulting array is computed on the heap and must be
deallocated after use. */
-static struct section_offsets *
+static gdb::unique_xmalloc_ptr<struct section_offsets>
solib_aix_get_section_offsets (struct objfile *objfile,
lm_info_aix *info)
{
- struct section_offsets *offsets;
bfd *abfd = objfile->obfd;
- offsets = XCNEWVEC (struct section_offsets, objfile->num_sections);
+ gdb::unique_xmalloc_ptr<struct section_offsets> offsets
+ (XCNEWVEC (struct section_offsets, objfile->num_sections));
/* .text */
@@ -515,12 +515,10 @@ solib_aix_solib_create_inferior_hook (int from_tty)
if (symfile_objfile != NULL)
{
- struct section_offsets *offsets
+ gdb::unique_xmalloc_ptr<struct section_offsets> offsets
= solib_aix_get_section_offsets (symfile_objfile, exec_info);
- struct cleanup *cleanup = make_cleanup (xfree, offsets);
- objfile_relocate (symfile_objfile, offsets);
- do_cleanups (cleanup);
+ objfile_relocate (symfile_objfile, offsets.get ());
}
}