summaryrefslogtreecommitdiff
path: root/gdb/solib-darwin.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-05-27 09:31:26 -0600
committerTom Tromey <tom@tromey.com>2018-06-18 13:26:32 -0600
commit668eb2f045ea535976cf484355831a8808b5ff35 (patch)
tree21ffd343038c1d86f25be92c5286c25975f6e782 /gdb/solib-darwin.c
parent309822ca289d602b9f9baf4760329ddd08b1d204 (diff)
downloadbinutils-gdb-668eb2f045ea535976cf484355831a8808b5ff35.tar.gz
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.
Diffstat (limited to 'gdb/solib-darwin.c')
-rw-r--r--gdb/solib-darwin.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index e655110d2d5..ed8e0c13365 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;