diff options
author | Tom Tromey <tom@tromey.com> | 2016-11-08 20:32:50 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2016-11-12 10:34:47 -0700 |
commit | 8001f1183f32d674fa3e9af1cca16856afdffc3e (patch) | |
tree | e6a20d7f11303ceb1c3bd6825d80ec5d13a61e78 /gdb/rust-lang.c | |
parent | d93f4d96bb0fb307db9e2dade38ddb3c6bc469ca (diff) | |
download | gdb-8001f1183f32d674fa3e9af1cca16856afdffc3e.zip gdb-8001f1183f32d674fa3e9af1cca16856afdffc3e.tar.gz gdb-8001f1183f32d674fa3e9af1cca16856afdffc3e.tar.bz2 |
Remove some cleanups from the rust code
This removes some cleanups from the rust code, in favor of C++ objects
with destructors.
2016-11-12 Tom Tromey <tom@tromey.com>
* rust-exp.y (super_name): Use std::vector.
(lex_number): Use std::string.
(convert_params_to_types): Return std::vector.
(convert_ast_to_type, convert_name): Update.
* rust-lang.c (rust_get_disr_info): Use unique_xmalloc_ptr.
Diffstat (limited to 'gdb/rust-lang.c')
-rw-r--r-- | gdb/rust-lang.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 7d4bfc3..4ba4263 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -145,7 +145,7 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr, if (strncmp (TYPE_FIELD_NAME (type, 0), RUST_ENUM_PREFIX, strlen (RUST_ENUM_PREFIX)) == 0) { - char *tail, *token, *name, *saveptr = NULL; + char *tail, *token, *saveptr = NULL; unsigned long fieldno; struct type *member_type; LONGEST value; @@ -158,9 +158,8 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr, /* Optimized enums have only one field. */ member_type = TYPE_FIELD_TYPE (type, 0); - name = xstrdup (TYPE_FIELD_NAME (type, 0)); - cleanup = make_cleanup (xfree, name); - tail = name + strlen (RUST_ENUM_PREFIX); + gdb::unique_xmalloc_ptr<char> name (xstrdup (TYPE_FIELD_NAME (type, 0))); + tail = name.get () + strlen (RUST_ENUM_PREFIX); /* The location of the value that doubles as a discriminant is stored in the name of the field, as @@ -203,7 +202,6 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr, + rust_last_path_segment (TYPE_NAME (TYPE_FIELD_TYPE (type, 0)))); } - do_cleanups (cleanup); return ret; } |