/* Rust language support routines for GDB, the GNU debugger.
- Copyright (C) 2016 Free Software Foundation, Inc.
+ Copyright (C) 2016-2017 Free Software Foundation, Inc.
This file is part of GDB.
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;
/* 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
+ rust_last_path_segment (TYPE_NAME (TYPE_FIELD_TYPE (type, 0))));
}
- do_cleanups (cleanup);
return ret;
}