Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Remove a cleanup from trace_dump_actions
@ 2018-05-19 16:06 Tom Tromey
  2018-05-20 23:58 ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2018-05-19 16:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes trace_dump_actions to use std::string, removing a
cleanup.

Tested by the buildbot.

gdb/ChangeLog
2018-05-19  Tom Tromey  <tom@tromey.com>

	* tracepoint.c (trace_dump_actions): Use std::string.
---
 gdb/ChangeLog    |  4 ++++
 gdb/tracepoint.c | 20 ++++----------------
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index e170d704bc..d83af78dd5 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2679,9 +2679,6 @@ trace_dump_actions (struct command_line *action,
 	     STEPPING_ACTIONS should be equal.  */
 	  if (stepping_frame == stepping_actions)
 	    {
-	      char *cmd = NULL;
-	      struct cleanup *old_chain
-		= make_cleanup (free_current_contents, &cmd);
 	      int trace_string = 0;
 
 	      if (*action_exp == '/')
@@ -2706,20 +2703,13 @@ trace_dump_actions (struct command_line *action,
 		    info_args_command (NULL, from_tty);
 		  else
 		    {		/* variable */
+		      std::string contents;
+		      const char *cmd = action_exp;
 		      if (next_comma != NULL)
 			{
 			  size_t len = next_comma - action_exp;
-
-			  cmd = (char *) xrealloc (cmd, len + 1);
-			  memcpy (cmd, action_exp, len);
-			  cmd[len] = 0;
-			}
-		      else
-			{
-			  size_t len = strlen (action_exp);
-
-			  cmd = (char *) xrealloc (cmd, len + 1);
-			  memcpy (cmd, action_exp, len + 1);
+			  contents = std::string (action_exp, len);
+			  cmd = contents.c_str ();
 			}
 
 		      printf_filtered ("%s = ", cmd);
@@ -2729,8 +2719,6 @@ trace_dump_actions (struct command_line *action,
 		  action_exp = next_comma;
 		}
 	      while (action_exp && *action_exp == ',');
-
-	      do_cleanups (old_chain);
 	    }
 	}
     }
-- 
2.13.6


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-21 15:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-19 16:06 [RFA] Remove a cleanup from trace_dump_actions Tom Tromey
2018-05-20 23:58 ` Simon Marchi
2018-05-21 16:04   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox