mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 09:08:59 +00:00
Use unique_xmalloc_ptr in interp
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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -78,20 +78,20 @@ public:
|
||||
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user