public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: add constructor to internalvar
@ 2023-02-15 17:00 Simon Marchi
0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2023-02-15 17:00 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dbca589b8d72316a5884321747b6ab92c6b34dbc
commit dbca589b8d72316a5884321747b6ab92c6b34dbc
Author: Simon Marchi <simon.marchi@efficios.com>
Date: Tue Feb 14 14:23:26 2023 -0500
gdb: add constructor to internalvar
Add a constructor that takes the name as a parameter. Initialize the
next and kind fields inline.
Change-Id: Ic4db0aba85f1da9f12f3eee0ac62c0e5ef0cfe88
Approved-By: Tom Tromey <tom@tromey.com>
Diff:
---
gdb/value.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/gdb/value.c b/gdb/value.c
index 4b3ec771266..1b74a6ecc4f 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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-15 17:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-15 17:00 [binutils-gdb] gdb: add constructor to internalvar Simon Marchi
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).