From 39e7af3e4b4e6c9f39d8d58cae73a2d307e6e1a1 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sun, 26 Aug 2018 11:53:47 -0400 Subject: Make ada-lang.c::add_angle_brackets return an std::string This removes the need for manual memory management. It may also be a bit more efficient, since the returned string can be moved all the way into the destination, in ada_lookup_name_info::matches. gdb/ChangeLog: * ada-lang.c (add_angle_brackets): Return std::string. --- gdb/ada-lang.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'gdb/ada-lang.c') diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index db5334d..d9d3087 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -541,17 +541,12 @@ ada_unqualified_name (const char *decoded_name) return result; } -/* Return a string starting with '<', followed by STR, and '>'. - The result is good until the next call. */ +/* Return a string starting with '<', followed by STR, and '>'. */ -static char * +static std::string add_angle_brackets (const char *str) { - static char *result = NULL; - - xfree (result); - result = xstrprintf ("<%s>", str); - return result; + return string_printf ("<%s>", str); } static const char * -- cgit v1.1