gdb: (de-)allocate target_desc_info with new/delete
authorSimon Marchi <simon.marchi@polymtl.ca>
Fri, 7 May 2021 20:28:56 +0000 (16:28 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Fri, 7 May 2021 20:28:56 +0000 (16:28 -0400)
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

gdb/ChangeLog
gdb/target-descriptions.c

index 604403c59cd1b23235b61df3f791d1023fe5ef00..e9c515640f32c04161782b8187c7d6bc0f1aa250 100644 (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>:
index 78dc89ac99fcb7eee35184748e0c35643a340795..4e0846a1a0b69b95bccbb1cf6517b70ddda72d5d 100644 (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;
     }
 }
 
This page took 0.029676 seconds and 4 git commands to generate.