Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 2/2] Remove last cleanup from btrace code
Date: Thu, 07 Jun 2018 22:44:00 -0000	[thread overview]
Message-ID: <20180607224426.6403-3-tom@tromey.com> (raw)
In-Reply-To: <20180607224426.6403-1-tom@tromey.com>

This removes the last cleanup from btrace.c, replacing it with a use
of unique_xmalloc_ptr.

2018-06-07  Tom Tromey  <tom@tromey.com>

	* btrace.c (parse_xml_raw): Use gdb::unique_xmalloc_ptr.
---
 gdb/ChangeLog |  4 ++++
 gdb/btrace.c  | 11 ++++-------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/gdb/btrace.c b/gdb/btrace.c
index 690770572e8..b8894a24ba0 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -2056,8 +2056,7 @@ static void
 parse_xml_raw (struct gdb_xml_parser *parser, const char *body_text,
 	       gdb_byte **pdata, size_t *psize)
 {
-  struct cleanup *cleanup;
-  gdb_byte *data, *bin;
+  gdb_byte *bin;
   size_t len, size;
 
   len = strlen (body_text);
@@ -2066,8 +2065,8 @@ parse_xml_raw (struct gdb_xml_parser *parser, const char *body_text,
 
   size = len / 2;
 
-  bin = data = (gdb_byte *) xmalloc (size);
-  cleanup = make_cleanup (xfree, data);
+  gdb::unique_xmalloc_ptr<gdb_byte> data ((gdb_byte *) xmalloc (size));
+  bin = data.get ();
 
   /* We use hex encoding - see common/rsp-low.h.  */
   while (len > 0)
@@ -2084,9 +2083,7 @@ parse_xml_raw (struct gdb_xml_parser *parser, const char *body_text,
       len -= 2;
     }
 
-  discard_cleanups (cleanup);
-
-  *pdata = data;
+  *pdata = data.release ();
   *psize = size;
 }
 
-- 
2.13.6


  reply	other threads:[~2018-06-07 22:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07 22:44 [RFA 0/2] remove cleanups " Tom Tromey
2018-06-07 22:44 ` Tom Tromey [this message]
2018-06-07 22:44 ` [RFA 1/2] Remove " Tom Tromey
2018-06-08  7:09 ` [RFA 0/2] remove " Metzger, Markus T

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180607224426.6403-3-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox