[RFA,06/10] Remove a string copy from event_location_to_sals

Message ID 20180401163539.15314-7-tom@tromey.com
State Superseded
Headers show
Series
  • Remove some cleanups from linespec.c
Related show

Commit Message

Tom Tromey April 1, 2018, 4:35 p.m.
The use of "const" showed that a string copy in event_location_to_sals
was unnecessary.  This patch removes it.

2018-03-31  Tom Tromey  <tom@tromey.com>

	* linespec.c (event_location_to_sals) <case ADDRESS_LOCATION>:
	Remove a string copy.
---
 gdb/ChangeLog  | 5 +++++
 gdb/linespec.c | 8 +-------
 2 files changed, 6 insertions(+), 7 deletions(-)

-- 
2.13.6

Patch

diff --git a/gdb/linespec.c b/gdb/linespec.c
index ca916a2a1d..48168eaaa6 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -3168,16 +3168,10 @@  event_location_to_sals (linespec_parser *parser,
 
 	if (addr_string != NULL)
 	  {
-	    char *expr = xstrdup (addr_string);
-	    const char *const_expr = expr;
-	    struct cleanup *cleanup = make_cleanup (xfree, expr);
-
-	    addr = linespec_expression_to_pc (&const_expr);
+	    addr = linespec_expression_to_pc (&addr_string);
 	    if (PARSER_STATE (parser)->canonical != NULL)
 	      PARSER_STATE (parser)->canonical->location
 		= copy_event_location (location);
-
-	    do_cleanups (cleanup);
 	  }
 
 	result = convert_address_location_to_sals (PARSER_STATE (parser),