From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 1/3] Use unique_xmalloc_ptr in interp
Date: Mon, 20 Jun 2022 07:46:48 -0600 [thread overview]
Message-ID: <20220620134650.2664575-2-tromey@adacore.com> (raw)
In-Reply-To: <20220620134650.2664575-1-tromey@adacore.com>
This changes interp::m_name to be a unique_xmalloc_ptr, removing some
manual memory management. It also cleans up the initialization of the
'inited' member, and moves the 'private:' and 'public:' keywords to
their proper spots.
---
gdb/interps.c | 4 +---
gdb/interps.h | 10 +++++-----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/gdb/interps.c b/gdb/interps.c
index 44002ff2cb5..0c440e78685 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -79,14 +79,12 @@ static struct interp *interp_lookup_existing (struct ui *ui,
const char *name);
interp::interp (const char *name)
- : m_name (xstrdup (name))
+ : m_name (make_unique_xstrdup (name))
{
- this->inited = false;
}
interp::~interp ()
{
- xfree (m_name);
}
/* An interpreter factory. Maps an interpreter name to the factory
diff --git a/gdb/interps.h b/gdb/interps.h
index 330c1ba6615..e393b08c962 100644
--- a/gdb/interps.h
+++ b/gdb/interps.h
@@ -78,20 +78,20 @@ class interp
const char *name () const
{
- return m_name;
+ return m_name.get ();
}
- /* This is the name in "-i=" and "set interpreter". */
private:
- char *m_name;
+ /* This is the name in "-i=" and "set interpreter". */
+ gdb::unique_xmalloc_ptr<char> m_name;
+public:
/* Interpreters are stored in a linked list, this is the next
one... */
-public:
struct interp *next;
/* Has the init method been run? */
- bool inited;
+ bool inited = false;
};
/* Look up the interpreter for NAME, creating one if none exists yet.
--
2.34.1
next prev parent reply other threads:[~2022-06-20 13:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 13:46 [PATCH 0/3] Minor improvements to 'interp' Tom Tromey
2022-06-20 13:46 ` Tom Tromey [this message]
2022-06-20 13:46 ` [PATCH 2/3] Move mi_interpreter to mi-interp.h Tom Tromey
2022-06-20 13:46 ` [PATCH 3/3] Use std::string for interpreter_p Tom Tromey
2022-06-21 12:11 ` Andrew Burgess
2022-06-22 19:50 ` 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=20220620134650.2664575-2-tromey@adacore.com \
--to=tromey@adacore.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).