diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-05-07 16:28:56 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-05-07 16:28:56 -0400 |
commit | 0b2f7ade5352e698ded54760ee8b34092fdd164f (patch) | |
tree | 83cdc4158db66e4fba4371f24ccb36591179d7c6 | |
parent | 820c449092aaee52e96676ffd7c9760126b85ad7 (diff) | |
download | binutils-0b2f7ade5352e698ded54760ee8b34092fdd164f.zip binutils-0b2f7ade5352e698ded54760ee8b34092fdd164f.tar.gz binutils-0b2f7ade5352e698ded54760ee8b34092fdd164f.tar.bz2 |
gdb: (de-)allocate target_desc_info with new/delete
In preparation for using non-POD types in the struct.
gdb/ChangeLog:
* target-descriptions.c (struct target_desc_info): Initialize
fields.
(get_tdesc_info): Use new.
(target_desc_info_free): Use delete.
Change-Id: I10fdaeeae7cdbd7930ae7adeeb13f7f363c67c7a
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/target-descriptions.c | 11 |
2 files changed, 13 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 604403c..e9c5156 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2021-05-07 Simon Marchi <simon.marchi@polymtl.ca> + * target-descriptions.c (struct target_desc_info): Initialize + fields. + (get_tdesc_info): Use new. + (target_desc_info_free): Use delete. + +2021-05-07 Simon Marchi <simon.marchi@polymtl.ca> + * target-descriptions.c (struct target_desc_info) <fetched>: bool. (target_find_description): Adjust. diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 78dc89a..4e0846a 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -446,7 +446,7 @@ struct target_desc_info /* A flag indicating that a description has already been fetched from the target, so it should not be queried again. */ - bool fetched; + bool fetched = false; /* The description fetched from the target, or NULL if the target did not supply any description. Only valid when @@ -454,12 +454,12 @@ struct target_desc_info code should access this; normally, the description should be accessed through the gdbarch object. */ - const struct target_desc *tdesc; + const struct target_desc *tdesc = nullptr; /* The filename to read a target description from, as set by "set tdesc filename ..." */ - char *filename; + char *filename = nullptr; }; /* Get the inferior INF's target description info, allocating one on @@ -469,7 +469,8 @@ static struct target_desc_info * get_tdesc_info (struct inferior *inf) { if (inf->tdesc_info == NULL) - inf->tdesc_info = XCNEW (struct target_desc_info); + inf->tdesc_info = new target_desc_info; + return inf->tdesc_info; } @@ -507,7 +508,7 @@ target_desc_info_free (struct target_desc_info *tdesc_info) if (tdesc_info != NULL) { xfree (tdesc_info->filename); - xfree (tdesc_info); + delete tdesc_info; } } |