From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id BB05C3856DDD; Wed, 22 Jun 2022 19:50:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB05C3856DDD Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Use unique_xmalloc_ptr in interp X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 90b7a5df152a64d2bea20beb438e8b81049a5c30 X-Git-Newrev: 3af607d998587de460b9e29996b1d43fa40a76b0 Message-Id: <20220622195046.BB05C3856DDD@sourceware.org> Date: Wed, 22 Jun 2022 19:50:46 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jun 2022 19:50:46 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D3af607d99858= 7de460b9e29996b1d43fa40a76b0 commit 3af607d998587de460b9e29996b1d43fa40a76b0 Author: Tom Tromey Date: Fri Jun 17 09:31:44 2022 -0600 Use unique_xmalloc_ptr in interp =20 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. Diff: --- 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); =20 interp::interp (const char *name) - : m_name (xstrdup (name)) + : m_name (make_unique_xstrdup (name)) { - this->inited =3D false; } =20 interp::~interp () { - xfree (m_name); } =20 /* 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 @@ public: =20 const char *name () const { - return m_name; + return m_name.get (); } =20 - /* This is the name in "-i=3D" and "set interpreter". */ private: - char *m_name; + /* This is the name in "-i=3D" and "set interpreter". */ + gdb::unique_xmalloc_ptr m_name; =20 +public: /* Interpreters are stored in a linked list, this is the next one... */ -public: struct interp *next; =20 /* Has the init method been run? */ - bool inited; + bool inited =3D false; }; =20 /* Look up the interpreter for NAME, creating one if none exists yet.