public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/4] gdb: (de-)allocate target_desc_info with new/delete
Date: Thu,  6 May 2021 12:49:56 -0400	[thread overview]
Message-ID: <20210506164957.101572-3-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20210506164957.101572-1-simon.marchi@polymtl.ca>

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/target-descriptions.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index aee1478301b6..341020fed762 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;
     }
 }
 
-- 
2.30.1


  parent reply	other threads:[~2021-05-06 16:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-06 16:49 [PATCH 1/4] gdb: remove target description macros Simon Marchi
2021-05-06 16:49 ` [PATCH 2/4] gdb: change target_desc_info::fetched to bool Simon Marchi
2021-05-07 10:18   ` Andrew Burgess
2021-05-06 16:49 ` Simon Marchi [this message]
2021-05-07 10:20   ` [PATCH 3/4] gdb: (de-)allocate target_desc_info with new/delete Andrew Burgess
2021-05-06 16:49 ` [PATCH 4/4] gdb: make target_desc_info::filename an std::string Simon Marchi
2021-05-07 10:22   ` Andrew Burgess
2021-05-07 20:31     ` Simon Marchi
2021-05-07 10:17 ` [PATCH 1/4] gdb: remove target description macros Andrew Burgess
2021-05-07 19:42   ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210506164957.101572-3-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).