+2017-12-05 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * target-descriptions.c (tdesc_feature) <name>: Change type to
+ std::string.
+ <~tdesc_feature>: Don't manually free name.
+ <operator==>: Adjust.
+ (tdesc_find_feature): Adjust.
+ (tdesc_feature_name): Adjust.
+ (class print_c_tdesc) <visit_pre>: Adjust.
+ (class print_c_feature) <visit_pre>: Adjust.
+
2017-12-05 Simon Marchi <simon.marchi@polymtl.ca>
* target-descriptions.c (tdesc_feature_p): Remove typedef.
struct tdesc_feature : tdesc_element
{
- tdesc_feature (const char *name_)
- : name (xstrdup (name_))
+ tdesc_feature (const std::string &name_)
+ : name (name_)
{}
virtual ~tdesc_feature ()
for (ix = 0; VEC_iterate (tdesc_type_p, types, ix, type); ix++)
delete type;
VEC_free (tdesc_type_p, types);
-
- xfree (name);
}
DISABLE_COPY_AND_ASSIGN (tdesc_feature);
/* The name of this feature. It may be recognized by the architecture
support code. */
- char *name;
+ std::string name;
/* The registers associated with this feature. */
VEC(tdesc_reg_p) *registers = NULL;
bool operator== (const tdesc_feature &other) const
{
- if (strcmp (name, other.name) != 0)
+ if (name != other.name)
return false;
if (VEC_length (tdesc_reg_p, registers)
const char *name)
{
for (const tdesc_feature_up &feature : target_desc->features)
- if (strcmp (feature->name, name) == 0)
+ if (feature->name == name)
return feature.get ();
return NULL;
const char *
tdesc_feature_name (const struct tdesc_feature *feature)
{
- return feature->name;
+ return feature->name.c_str ();
}
/* Predefined types. */
void visit_pre (const tdesc_feature *e) override
{
printf_unfiltered ("\n feature = tdesc_create_feature (result, \"%s\");\n",
- e->name);
+ e->name.c_str ());
}
void visit_post (const tdesc_feature *e) override
printf_unfiltered
("\n feature = tdesc_create_feature (result, \"%s\", \"%s\");\n",
- e->name, lbasename (m_filename_after_features.c_str ()));
+ e->name.c_str (), lbasename (m_filename_after_features.c_str ()));
}
void visit_post (const tdesc_feature *e) override