From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH v2 2/3] gdb: add constructor to internalvar
Date: Tue, 14 Feb 2023 14:23:26 -0500 [thread overview]
Message-ID: <20230214192327.318301-2-simon.marchi@efficios.com> (raw)
In-Reply-To: <20230214192327.318301-1-simon.marchi@efficios.com>
Add a constructor that takes the name as a parameter. Initialize the
Change-Id: Ic4db0aba85f1da9f12f3eee0ac62c0e5ef0cfe88
---
gdb/value.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/gdb/value.c b/gdb/value.c
index 936949f4a1f1..7fd11ba70db6 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1829,14 +1829,18 @@ union internalvar_data
struct internalvar
{
- struct internalvar *next;
+ internalvar (std::string name)
+ : name (std::move (name))
+ {}
+
+ struct internalvar *next = nullptr;
std::string name;
/* We support various different kinds of content of an internal variable.
enum internalvar_kind specifies the kind, and union internalvar_data
provides the data associated with this particular kind. */
- enum internalvar_kind kind;
+ enum internalvar_kind kind = INTERNALVAR_VOID;
union internalvar_data u;
};
@@ -1922,10 +1926,8 @@ complete_internalvar (completion_tracker &tracker, const char *name)
struct internalvar *
create_internalvar (const char *name)
{
- internalvar *var = new internalvar;
+ internalvar *var = new internalvar (name);
- var->name = name;
- var->kind = INTERNALVAR_VOID;
var->next = internalvars;
internalvars = var;
return var;
--
2.39.1
next prev parent reply other threads:[~2023-02-14 19:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-14 19:23 [PATCH v2 1/3] gdb: use std::string for internalvar::name Simon Marchi
2023-02-14 19:23 ` Simon Marchi [this message]
2023-02-14 20:42 ` [PATCH v2 2/3] gdb: add constructor to internalvar Tom Tromey
2023-02-15 16:38 ` Simon Marchi
2023-02-15 16:56 ` Tom Tromey
2023-02-15 16:58 ` Simon Marchi
2023-02-14 19:23 ` [PATCH v2 3/3] gdb: store internalvars in an std::map Simon Marchi
2023-02-14 20:46 ` Tom Tromey
2023-02-14 20:37 ` [PATCH v2 1/3] gdb: use std::string for internalvar::name Tom Tromey
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=20230214192327.318301-2-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--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).