Use unique_xmalloc_ptr in remote.c
authorTom Tromey <tom@tromey.com>
Thu, 14 Feb 2019 23:10:01 +0000 (16:10 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 6 Mar 2019 23:04:31 +0000 (16:04 -0700)
This removes a cleanup from remote.c, replacing it with
unique_xmalloc_ptr.

2019-03-06  Tom Tromey  <tom@tromey.com>

* remote.c (remote_target::remote_parse_stop_reply): Use
unique_xmalloc_ptr.

gdb/ChangeLog
gdb/remote.c

index ef323e126cbe4e5eb1f2d1aa734fee58b7d784d9..38ce62f6b80084cfd0e80a34816a26fedb196d2a 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-06  Tom Tromey  <tom@tromey.com>
+
+       * remote.c (remote_target::remote_parse_stop_reply): Use
+       unique_xmalloc_ptr.
+
 2019-03-06  Tom Tromey  <tom@tromey.com>
 
        * stabsread.c (struct stabs_field_info): Rename from field_info.
index 7d556add0df354e1391a4c5fb0896685b9a7ee16..ef12fe9a3b42b0d7ddfa3ffe521198ca59b38a3f 100644 (file)
@@ -7312,14 +7312,13 @@ Packet: '%s'\n"),
 
              /* Save the pathname for event reporting and for
                 the next run command.  */
-             char *pathname = (char *) xmalloc (pathlen + 1);
-             struct cleanup *old_chain = make_cleanup (xfree, pathname);
-             hex2bin (p1, (gdb_byte *) pathname, pathlen);
+             gdb::unique_xmalloc_ptr<char[]> pathname
+               ((char *) xmalloc (pathlen + 1));
+             hex2bin (p1, (gdb_byte *) pathname.get (), pathlen);
              pathname[pathlen] = '\0';
-             discard_cleanups (old_chain);
 
              /* This is freed during event handling.  */
-             event->ws.value.execd_pathname = pathname;
+             event->ws.value.execd_pathname = pathname.release ();
              event->ws.kind = TARGET_WAITKIND_EXECD;
 
              /* Skip the registers included in this packet, since