diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-06-25 17:54:55 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-07-23 15:38:54 -0400 |
commit | fd2dec2a45a73154d9824071ebb8664a39a69174 (patch) | |
tree | 2297cdb9fa147b25a87d354a0f7e1452f71a64d3 /gdb/inferior.h | |
parent | 90cc31c9e59a75122c2371fdf43f53d91e6ad5d6 (diff) | |
download | gdb-fd2dec2a45a73154d9824071ebb8664a39a69174.zip gdb-fd2dec2a45a73154d9824071ebb8664a39a69174.tar.gz gdb-fd2dec2a45a73154d9824071ebb8664a39a69174.tar.bz2 |
gdb: make inferior::m_args an std::string
With the current code, both a NULL pointer and an empty string can mean
"no arguments". We don't need this distinction. Changing to a string
has the advantage that there is now a single state for that (an empty
string), which makes the code a bit simpler in my opinion.
Change-Id: Icdc622820f7869478791dbaa84b4a1c7fec21ced
Diffstat (limited to 'gdb/inferior.h')
-rw-r--r-- | gdb/inferior.h | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/gdb/inferior.h b/gdb/inferior.h index fb57df7..72f2c29 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -444,26 +444,18 @@ public: /* Set the argument string to use when running this inferior. - Either nullptr or an empty string can be used to represent "no - arguments". */ - void set_args (const char *args) + An empty string can be used to represent "no arguments". */ + void set_args (std::string args) { - if (args != nullptr && args[0] != '\0') - m_args = make_unique_xstrdup (args); - else - m_args.reset (); + m_args = std::move (args); }; /* Get the argument string to use when running this inferior. - The return value is always non-nullptr. No arguments is represented by - an empty string. */ - const char *args () const + No arguments is represented by an empty string. */ + const std::string &args () const { - if (m_args == nullptr) - return ""; - - return m_args.get (); + return m_args; } /* Set the inferior current working directory. @@ -602,10 +594,8 @@ private: /* The list of continuations. */ std::list<std::function<void ()>> m_continuations; - /* The arguments string to use when running. - - This is nullptr when there are not args. */ - gdb::unique_xmalloc_ptr<char> m_args; + /* The arguments string to use when running. */ + std::string m_args; /* The current working directory that will be used when starting this inferior. */ |