aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2017-07-26 10:37:17 +0100
committerYao Qi <yao.qi@linaro.org>2017-07-26 10:37:17 +0100
commitb468ff4cbf14744d512e464b4be9681d3e0302ad (patch)
treeb7d8137ab4cfbd0051dd088a935952d8530a2cc6
parent229d26fc9ebca61b8d899cf8fe4342a6cc9795ff (diff)
downloadgdb-b468ff4cbf14744d512e464b4be9681d3e0302ad.zip
gdb-b468ff4cbf14744d512e464b4be9681d3e0302ad.tar.gz
gdb-b468ff4cbf14744d512e464b4be9681d3e0302ad.tar.bz2
Class-fy target_desc
This patch adds ctor and dtor in target_desc. gdb: 2017-07-26 Yao Qi <yao.qi@linaro.org> * target-descriptions.c (target_desc): Add ctor and dtor. Do in-class initialization. (tdesc_create_feature): Call new instead of XCNEW. (free_target_description): Ue delete.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/target-descriptions.c64
2 files changed, 44 insertions, 27 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b3f9c7b..be39af6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2017-07-26 Yao Qi <yao.qi@linaro.org>
+
+ * target-descriptions.c (target_desc): Add ctor and dtor. Do
+ in-class initialization.
+ (tdesc_create_feature): Call new instead of XCNEW.
+ (free_target_description): Ue delete.
+
2017-07-25 John Baldwin <jhb@FreeBSD.org>
* configure.nat: Add "-lkvm" for NetBSD/sparc64 and fix typo.
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 0b5b46f..9484f01 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -267,21 +267,51 @@ DEF_VEC_P(arch_p);
struct target_desc
{
+ target_desc ()
+ {}
+
+ ~target_desc ()
+ {
+ struct tdesc_feature *feature;
+ struct property *prop;
+ int ix;
+
+ for (ix = 0;
+ VEC_iterate (tdesc_feature_p, features, ix, feature);
+ ix++)
+ delete feature;
+ VEC_free (tdesc_feature_p, features);
+
+ for (ix = 0;
+ VEC_iterate (property_s, properties, ix, prop);
+ ix++)
+ {
+ xfree (prop->key);
+ xfree (prop->value);
+ }
+
+ VEC_free (property_s, properties);
+ VEC_free (arch_p, compatible);
+ }
+
+ target_desc (const target_desc &) = delete;
+ void operator= (const target_desc &) = delete;
+
/* The architecture reported by the target, if any. */
- const struct bfd_arch_info *arch;
+ const struct bfd_arch_info *arch = NULL;
/* The osabi reported by the target, if any; GDB_OSABI_UNKNOWN
otherwise. */
- enum gdb_osabi osabi;
+ enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
/* The list of compatible architectures reported by the target. */
- VEC(arch_p) *compatible;
+ VEC(arch_p) *compatible = NULL;
/* Any architecture-specific properties specified by the target. */
- VEC(property_s) *properties;
+ VEC(property_s) *properties = NULL;
/* The features associated with this target. */
- VEC(tdesc_feature_p) *features;
+ VEC(tdesc_feature_p) *features = NULL;
};
/* Per-architecture data associated with a target description. The
@@ -1551,35 +1581,15 @@ tdesc_create_feature (struct target_desc *tdesc, const char *name)
struct target_desc *
allocate_target_description (void)
{
- return XCNEW (struct target_desc);
+ return new target_desc ();
}
static void
free_target_description (void *arg)
{
struct target_desc *target_desc = (struct target_desc *) arg;
- struct tdesc_feature *feature;
- struct property *prop;
- int ix;
-
- for (ix = 0;
- VEC_iterate (tdesc_feature_p, target_desc->features, ix, feature);
- ix++)
- delete feature;
- VEC_free (tdesc_feature_p, target_desc->features);
-
- for (ix = 0;
- VEC_iterate (property_s, target_desc->properties, ix, prop);
- ix++)
- {
- xfree (prop->key);
- xfree (prop->value);
- }
- VEC_free (property_s, target_desc->properties);
-
- VEC_free (arch_p, target_desc->compatible);
- xfree (target_desc);
+ delete target_desc;
}
struct cleanup *