forked from Imagelibrary/binutils-gdb
gdb: remove use of alloca in new_macro_definition
Replace alloca with std::vector. Change-Id: Ie8756da09126f6808e5b52c43388ad9324e8ad2c Approved-By: Tom de Vries <tdevries@suse.de>
This commit is contained in:
@@ -564,15 +564,14 @@ new_macro_definition (macro_table *t, macro_kind kind,
|
|||||||
d->argc = argv.size ();
|
d->argc = argv.size ();
|
||||||
|
|
||||||
/* Bcache all the arguments. */
|
/* Bcache all the arguments. */
|
||||||
int i = 0;
|
std::vector<const char *> cached_argv;
|
||||||
int cached_argv_size = argv.size () * sizeof (const char *);
|
|
||||||
const char **cached_argv = (const char **) alloca (cached_argv_size);
|
|
||||||
|
|
||||||
for (const auto &arg : argv)
|
for (const auto &arg : argv)
|
||||||
cached_argv[i++] = macro_bcache_str (t, arg.c_str ());
|
cached_argv.push_back (macro_bcache_str (t, arg.c_str ()));
|
||||||
|
|
||||||
/* Now bcache the array of argument pointers itself. */
|
/* Now bcache the array of argument pointers itself. */
|
||||||
d->argv = macro_bcache (t, cached_argv, cached_argv_size);
|
d->argv = macro_bcache (t, cached_argv.data (),
|
||||||
|
cached_argv.size () * sizeof (const char *));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
d->argc = special_kind;
|
d->argc = special_kind;
|
||||||
|
|||||||
Reference in New Issue
Block a user