This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Removes a cleanup from gcore.c


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=44287fd89091a833451e74c79e46404c23fdaf9b

commit 44287fd89091a833451e74c79e46404c23fdaf9b
Author: Tom Tromey <tom@tromey.com>
Date:   Thu Nov 9 17:15:37 2017 -0700

    Removes a cleanup from gcore.c
    
    This removes a cleanup from gcore.c, replacing it with
    unique_xmalloc_ptr.
    
    Regression tested by the buildbot.
    
    ChangeLog
    2017-11-26  Tom Tromey  <tom@tromey.com>
    
    	* gcore.c (write_gcore_file_1): Use gdb::unique_xmalloc_ptr.

Diff:
---
 gdb/ChangeLog |  4 ++++
 gdb/gcore.c   | 15 ++++++---------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6223f0d..3c74596 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2017-11-26  Tom Tromey  <tom@tromey.com>
+
+	* gcore.c (write_gcore_file_1): Use gdb::unique_xmalloc_ptr.
+
 2017-11-26  Ulrich Weigand  <uweigand@de.ibm.com>
 
 	* spu-tdep.c (spu_software_single_step): Access SPU_LSLR_REGNUM as
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 0d5dcca..359ec3d 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -68,8 +68,7 @@ create_gcore_bfd (const char *filename)
 static void
 write_gcore_file_1 (bfd *obfd)
 {
-  struct cleanup *cleanup;
-  void *note_data = NULL;
+  gdb::unique_xmalloc_ptr<char> note_data;
   int note_size = 0;
   asection *note_sec = NULL;
 
@@ -78,11 +77,10 @@ write_gcore_file_1 (bfd *obfd)
      generation should be converted to gdbarch_make_corefile_notes; at that
      point, the target vector method can be removed.  */
   if (!gdbarch_make_corefile_notes_p (target_gdbarch ()))
-    note_data = target_make_corefile_notes (obfd, &note_size);
+    note_data.reset (target_make_corefile_notes (obfd, &note_size));
   else
-    note_data = gdbarch_make_corefile_notes (target_gdbarch (), obfd, &note_size);
-
-  cleanup = make_cleanup (xfree, note_data);
+    note_data.reset (gdbarch_make_corefile_notes (target_gdbarch (), obfd,
+						  &note_size));
 
   if (note_data == NULL || note_size == 0)
     error (_("Target does not support core file generation."));
@@ -105,10 +103,9 @@ write_gcore_file_1 (bfd *obfd)
     error (_("gcore: failed to get corefile memory sections from target."));
 
   /* Write out the contents of the note section.  */
-  if (!bfd_set_section_contents (obfd, note_sec, note_data, 0, note_size))
+  if (!bfd_set_section_contents (obfd, note_sec, note_data.get (), 0,
+				 note_size))
     warning (_("writing note section (%s)"), bfd_errmsg (bfd_get_error ()));
-
-  do_cleanups (cleanup);
 }
 
 /* write_gcore_file -- helper for gcore_command (exported).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]