From: Simon Marchi Date: Fri, 7 May 2021 20:28:56 +0000 (-0400) Subject: gdb: (de-)allocate target_desc_info with new/delete X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0b2f7ade5352e698ded54760ee8b34092fdd164f;p=binutils-gdb.git 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 --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 604403c59cd..e9c515640f3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2021-05-07 Simon Marchi + + * 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 * target-descriptions.c (struct target_desc_info) : diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 78dc89ac99f..4e0846a1a0b 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; } }