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] Use unique_xmalloc_ptr in darwin_current_sos


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

commit 668eb2f045ea535976cf484355831a8808b5ff35
Author: Tom Tromey <tom@tromey.com>
Date:   Sun May 27 09:31:26 2018 -0600

    Use unique_xmalloc_ptr in darwin_current_sos
    
    This changes darwin_current_sos to use unique_xmalloc_ptr rather than
    a cleanup.
    
    gdb/ChangeLog
    2018-06-18  Tom Tromey  <tom@tromey.com>
    
    	* solib-darwin.c (darwin_current_sos): Use unique_xmalloc_ptr.

Diff:
---
 gdb/ChangeLog      |  4 ++++
 gdb/solib-darwin.c | 13 ++++---------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9c83a4a..c6112d2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 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>
+
 	* solib-frv.c (frv_relocate_main_executable): Use
 	unique_xmalloc_ptr.
 	* solib-dsbt.c (dsbt_relocate_main_executable): Use
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index e655110..ed8e0c1 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -263,8 +263,6 @@ darwin_current_sos (void)
       unsigned long hdr_val;
       gdb::unique_xmalloc_ptr<char> file_path;
       int errcode;
-      struct so_list *newobj;
-      struct cleanup *old_chain;
 
       /* Read image info from inferior.  */
       if (target_read_memory (iinfo, buf, image_info_size))
@@ -293,8 +291,7 @@ darwin_current_sos (void)
 	break;
 
       /* Create and fill the new so_list element.  */
-      newobj = XCNEW (struct so_list);
-      old_chain = make_cleanup (xfree, newobj);
+      gdb::unique_xmalloc_ptr<struct so_list> newobj (XCNEW (struct so_list));
 
       lm_info_darwin *li = new lm_info_darwin;
       newobj->lm_info = li;
@@ -305,12 +302,10 @@ darwin_current_sos (void)
       li->lm_addr = load_addr;
 
       if (head == NULL)
-	head = newobj;
+	head = newobj.get ();
       else
-	tail->next = newobj;
-      tail = newobj;
-
-      discard_cleanups (old_chain);
+	tail->next = newobj.get ();
+      tail = newobj.release ();
     }
 
   return head;


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