This is the mail archive of the gdb-patches@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]

[FYI 1/2] Use std::string in rust_get_disr_info


This changes rust_get_disr_info to use std::string in one more spot,
avoiding a memory leak.

2016-11-09  Tom Tromey  <tom@tromey.com>

	* rust-lang.c (rust_get_disr_info): Use std::string in one more
	spot.
---
 gdb/ChangeLog   | 5 +++++
 gdb/rust-lang.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9123596..66a711a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2016-11-09  Tom Tromey  <tom@tromey.com>
+
+	* rust-lang.c (rust_get_disr_info): Use std::string in one more
+	spot.
+
 2016-11-09  Pedro Alves  <palves@redhat.com>
 
 	* ax-gdb.c (agent_eval_command_one): Use std::move instead of
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 295dae1..7d4bfc3 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -222,7 +222,7 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr,
          with the first field being the actual type works.  */
       const char *field_name = TYPE_NAME (TYPE_FIELD_TYPE (type, 0));
       const char *last = rust_last_path_segment (field_name);
-      ret.name = concat (TYPE_NAME (type), "::", last, (char *) NULL);
+      ret.name = std::string (TYPE_NAME (type)) + "::" + last;
       ret.field_no = RUST_ENCODED_ENUM_REAL;
       ret.is_encoded = 1;
       return ret;
-- 
2.7.4


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