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] Remove last cleanup from btrace code


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

commit 343b0027aed57c5a2d499e7e6e228608969a10be
Author: Tom Tromey <tom@tromey.com>
Date:   Thu Jun 7 15:38:25 2018 -0600

    Remove last cleanup from btrace code
    
    This removes the last cleanup from btrace.c, replacing it with a use
    of unique_xmalloc_ptr.
    
    gdb/ChangeLog
    2018-06-08  Tom Tromey  <tom@tromey.com>
    
    	* btrace.c (parse_xml_raw): Use gdb::unique_xmalloc_ptr.

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

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index da002fa..4f732b5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2018-06-08  Tom Tromey  <tom@tromey.com>
 
+	* btrace.c (parse_xml_raw): Use gdb::unique_xmalloc_ptr.
+
+2018-06-08  Tom Tromey  <tom@tromey.com>
+
 	* common/btrace-common.h (struct btrace_data): Add constructor,
 	destructor, move assignment operator.
 	<empty, clear, fini>: New methods.
diff --git a/gdb/btrace.c b/gdb/btrace.c
index 6907705..b8894a2 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;
 }


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