diff options
author | Pedro Alves <palves@redhat.com> | 2017-04-13 11:46:07 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2017-04-13 11:46:07 +0100 |
commit | 808480f667e41e2fdb66bfdc9d5e047f1aa34a68 (patch) | |
tree | 6af17a76cdbe8aa21e47ea3e68c173f553c5dec4 /gdb/cris-tdep.h | |
parent | 8f0dd45fde9de100160f45cad3e537e4e01a5493 (diff) | |
download | gdb-808480f667e41e2fdb66bfdc9d5e047f1aa34a68.zip gdb-808480f667e41e2fdb66bfdc9d5e047f1aa34a68.tar.gz gdb-808480f667e41e2fdb66bfdc9d5e047f1aa34a68.tar.bz2 |
fork-child.c: Avoid unnecessary heap-allocation / string copying
The previous change to fork-child.c converted the argv building from
an alloca-allocated array of non-owning arg pointers, to a std::vector
of owning pointers, which results in N string dups, with N being the
number of arguments in the vector, and then requires manually
releasing the pointers owned by the vector.
This patch makes the vector hold non-owning pointers, and avoids the
string dups, by doing one single string copy of the arguments upfront,
and replacing separators with NULL terminators in place, like we used
to. All the logic to do that is encapsulated in a new class.
With this, there's no need to remember to manually release the argv
elements with free_vector_argv either.
gdb/ChangeLog:
2017-04-13 Pedro Alves <palves@redhat.com>
* fork-child.c (execv_argv): New class.
(breakup_args): Refactored as ...
(execv_argv::init_for_no_shell): .. this method of execv_argv.
Copy arguments to storage and replace separators with NULL
terminators in place.
(escape_bang_in_quoted_argument): Adjust to return bool.
(execv_argv::execv_argv): New ctor.
(execv_argv::init_for_shell): New method, factored out from
fork_inferior. Don't strdup strings into the vector.
(fork_inferior): Eliminate "shell" local and use execv_argv. Use
Remove free_vector_argv call.
Diffstat (limited to 'gdb/cris-tdep.h')
0 files changed, 0 insertions, 0 deletions