Skip to content

Commit

Permalink
gdb: remove use of alloca in new_macro_definition
Browse files Browse the repository at this point in the history
Replace alloca with std::vector.

Change-Id: Ie8756da09126f6808e5b52c43388ad9324e8ad2c
Approved-By: Tom de Vries <[email protected]>
  • Loading branch information
simark committed Jul 30, 2024
1 parent 1cb8a69 commit b1da98a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions gdb/macrotab.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,15 +564,14 @@ new_macro_definition (macro_table *t, macro_kind kind,
d->argc = argv.size ();

/* Bcache all the arguments. */
int i = 0;
int cached_argv_size = argv.size () * sizeof (const char *);
const char **cached_argv = (const char **) alloca (cached_argv_size);
std::vector<const char *> cached_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. */
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
d->argc = special_kind;
Expand Down

0 comments on commit b1da98a

Please sign in to comment.