diff options
author | Tom Tromey <tom@tromey.com> | 2021-06-04 16:00:33 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-11-05 13:58:48 -0600 |
commit | be77dd73c769b3e7ac62bd4c0b98242b62d080e0 (patch) | |
tree | 42467dc2ff4b18810660886835c51503b6ffacb7 /gdb/cli/cli-setshow.c | |
parent | 8a89ddbda2ecb41be0f12142e5d4b95c7bd5a138 (diff) | |
download | binutils-be77dd73c769b3e7ac62bd4c0b98242b62d080e0.zip binutils-be77dd73c769b3e7ac62bd4c0b98242b62d080e0.tar.gz binutils-be77dd73c769b3e7ac62bd4c0b98242b62d080e0.tar.bz2 |
Introduce make_unique_xstrndup
This adds a new make_unique_xstrndup function, which is the "n"
analogue of make_unique_xstrdup. It also updates a couple existing
places to use this function.
Diffstat (limited to 'gdb/cli/cli-setshow.c')
-rw-r--r-- | gdb/cli/cli-setshow.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index dcb50ca..18e2d4e 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -375,14 +375,13 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c) { /* Clear trailing whitespace of filename. */ const char *ptr = arg + strlen (arg) - 1; - char *copy; while (ptr >= arg && (*ptr == ' ' || *ptr == '\t')) ptr--; - copy = xstrndup (arg, ptr + 1 - arg); + gdb::unique_xmalloc_ptr<char> copy + = make_unique_xstrndup (arg, ptr + 1 - arg); - val = tilde_expand (copy); - xfree (copy); + val = tilde_expand (copy.get ()); } else val = xstrdup (""); |