public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Make ada-lang.c::add_angle_brackets return an std::string
@ 2018-08-20  1:50 Simon Marchi
  2018-08-20  1:50 ` [PATCH 2/2] Make ada_tasks_inferior_data::task_list an std::vector Simon Marchi
  2018-08-26 16:43 ` [PATCH 1/2] Make ada-lang.c::add_angle_brackets return an std::string Simon Marchi
  0 siblings, 2 replies; 3+ messages in thread
From: Simon Marchi @ 2018-08-20  1:50 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

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(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index db5334dd1e00..d9d3087642bc 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 *
-- 
2.18.0

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

end of thread, other threads:[~2018-08-26 16:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-20  1:50 [PATCH 1/2] Make ada-lang.c::add_angle_brackets return an std::string Simon Marchi
2018-08-20  1:50 ` [PATCH 2/2] Make ada_tasks_inferior_data::task_list an std::vector Simon Marchi
2018-08-26 16:43 ` [PATCH 1/2] Make ada-lang.c::add_angle_brackets return an std::string Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).