summaryrefslogtreecommitdiff
path: root/gdb/rust-exp.y
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-02-02 20:58:12 -0700
committerTom Tromey <tom@tromey.com>2017-02-02 21:25:11 -0700
commit03c85b11b07452f2d7341b405a7fe70c74226505 (patch)
tree3d87dc1f816b12136c8d84ad0bb23647330b7617 /gdb/rust-exp.y
parent73dceb99fa57b79e83a6ed80aaad49d0e3e7da66 (diff)
downloadbinutils-gdb-03c85b11b07452f2d7341b405a7fe70c74226505.tar.gz
Use std::string in Rust code
This changes a couple of spots in the Rust support to use std::string. In one spot this removes some manual memory management; in the other spot this allows the removal of a call to xstrdup. 2017-02-02 Tom Tromey <tom@tromey.com> * rust-lang.h (rust_crate_for_block): Update. * rust-lang.c (rust_crate_for_block): Return std::string. (rust_get_disr_info): Use std:;string, not gdb::unique_xmalloc_ptr. * rust-exp.y (crate_name): Update.
Diffstat (limited to 'gdb/rust-exp.y')
-rw-r--r--gdb/rust-exp.y7
1 files changed, 3 insertions, 4 deletions
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
index a97ca67f46e..98301a48922 100644
--- a/gdb/rust-exp.y
+++ b/gdb/rust-exp.y
@@ -941,16 +941,15 @@ rust_concat3 (const char *s1, const char *s2, const char *s3)
static const struct rust_op *
crate_name (const struct rust_op *name)
{
- char *crate = rust_crate_for_block (expression_context_block);
+ std::string crate = rust_crate_for_block (expression_context_block);
struct stoken result;
gdb_assert (name->opcode == OP_VAR_VALUE);
- if (crate == NULL)
+ if (crate.empty ())
error (_("Could not find crate for current location"));
- result = make_stoken (obconcat (&work_obstack, "::", crate, "::",
+ result = make_stoken (obconcat (&work_obstack, "::", crate.c_str (), "::",
name->left.sval.ptr, (char *) NULL));
- xfree (crate);
return ast_path (result, name->right.params);
}