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
This commit is contained in:
Simon Marchi 2021-05-07 16:28:56 -04:00
parent 820c449092
commit 0b2f7ade53
2 changed files with 13 additions and 5 deletions

View File

@ -1,3 +1,10 @@
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>:

View File

@ -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;
}
}