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.
This commit is contained in:
Tom Tromey 2016-11-08 20:32:50 -07:00
parent d93f4d96bb
commit 8001f1183f
3 changed files with 47 additions and 63 deletions

View file

@ -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;
}