From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 04/10] Make tdesc_feature::name an std::string
Date: Tue, 31 Oct 2017 01:42:00 -0000 [thread overview]
Message-ID: <1509414120-14659-5-git-send-email-simon.marchi@ericsson.com> (raw)
In-Reply-To: <1509414120-14659-1-git-send-email-simon.marchi@ericsson.com>
From: Simon Marchi <simon.marchi@polymtl.ca>
... so we don't have to manually free it in ~tdesc_feature.
gdb/ChangeLog:
* 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.
---
gdb/target-descriptions.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index eea5115..410575d 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -281,8 +281,8 @@ DEF_VEC_P(tdesc_type_p);
struct tdesc_feature : tdesc_element
{
- tdesc_feature (const char *name_)
- : name (xstrdup (name_))
+ tdesc_feature (const std::string &name_)
+ : name (name_)
{}
virtual ~tdesc_feature ()
@@ -298,15 +298,13 @@ struct tdesc_feature : tdesc_element
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;
@@ -338,7 +336,7 @@ struct tdesc_feature : tdesc_element
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)
@@ -741,7 +739,7 @@ tdesc_find_feature (const struct target_desc *target_desc,
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;
@@ -752,7 +750,7 @@ tdesc_find_feature (const struct target_desc *target_desc,
const char *
tdesc_feature_name (const struct tdesc_feature *feature)
{
- return feature->name;
+ return feature->name.c_str ();
}
/* Predefined types. */
@@ -1928,7 +1926,7 @@ public:
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
@@ -2146,7 +2144,7 @@ public:
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
--
2.7.4
next prev parent reply other threads:[~2017-10-31 1:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-31 1:42 [PATCH 00/10] Use std::vector and std::string throughout target-descriptions.c Simon Marchi
2017-10-31 1:42 ` [PATCH 10/10] Make tdesc_arch_data::arch_regs an std::vector Simon Marchi
2017-10-31 1:42 ` [PATCH 09/10] Make tdesc_type::u::u::fields " Simon Marchi
2017-11-02 10:02 ` Yao Qi
2017-11-02 13:27 ` Simon Marchi
2017-12-03 16:04 ` [PATCH 11/10] Split tdesc_type into multiple classes Simon Marchi
2017-12-05 16:46 ` Yao Qi
2017-12-05 21:42 ` Simon Marchi
2017-10-31 1:42 ` [PATCH 01/10] Make target_desc::properties an std::vector Simon Marchi
2017-10-31 1:42 ` [PATCH 08/10] Make tdesc_type::name an std::string Simon Marchi
2017-10-31 1:42 ` [PATCH 05/10] Make tdesc_feature::registers an std::vector Simon Marchi
2017-11-02 9:32 ` Yao Qi
2017-11-02 13:22 ` Simon Marchi
2017-10-31 1:42 ` [PATCH 07/10] Make tdesc_feature::types " Simon Marchi
2017-10-31 1:42 ` Simon Marchi [this message]
2017-10-31 1:42 ` [PATCH 06/10] Make tdesc_reg string fields std::string Simon Marchi
2017-11-02 9:43 ` Yao Qi
2017-11-02 13:24 ` Simon Marchi
2017-10-31 1:42 ` [PATCH 03/10] Make target_desc::features an std::vector Simon Marchi
2017-11-02 9:29 ` Yao Qi
2017-11-02 13:20 ` Simon Marchi
2017-10-31 1:43 ` [PATCH 02/10] Make target_desc::compatible " Simon Marchi
2017-11-02 10:16 ` [PATCH 00/10] Use std::vector and std::string throughout target-descriptions.c Yao Qi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1509414120-14659-5-git-send-email-simon.marchi@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox