Use unique_xmalloc_ptr in darwin_current_sos
authorTom Tromey <tom@tromey.com>
Sun, 27 May 2018 15:31:26 +0000 (09:31 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 18 Jun 2018 19:26:32 +0000 (13:26 -0600)
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.

gdb/ChangeLog
gdb/solib-darwin.c

index 9c83a4a2619c2ea908ae8636da39efb17efbb1fa..c6112d23e867e153c8d3eb528a94a7b3a9a6aa58 100644 (file)
@@ -1,3 +1,7 @@
+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
index e655110d2d5ed384ba804995dd359d8cf95a9830..ed8e0c13365609b76383b5435985afcc0648d1c1 100644 (file)
@@ -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;
This page took 0.037143 seconds and 4 git commands to generate.