aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbtypes.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2023-08-31 15:56:10 -0400
committerSimon Marchi <simon.marchi@efficios.com>2023-08-31 21:28:48 -0400
commit8ba212f8933df0560d600d14c032be251aa21a71 (patch)
tree4acac943362ba690d75406d374762f1757b095b0 /gdb/gdbtypes.c
parent9e2dda428d1c8e9a3eead8a77f40ab2de3e458cb (diff)
downloadgdb-8ba212f8933df0560d600d14c032be251aa21a71.zip
gdb-8ba212f8933df0560d600d14c032be251aa21a71.tar.gz
gdb-8ba212f8933df0560d600d14c032be251aa21a71.tar.bz2
gdb: remove uses of alloca in gdbtypes.c
Replace two uses of alloca with std::string. Change-Id: I970ae3f450da407494d95668a57bba8796d6292b Approved-by: Kevin Buettner <kevinb@redhat.com>
Diffstat (limited to 'gdb/gdbtypes.c')
-rw-r--r--gdb/gdbtypes.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 59ddd75..5e15ec6 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1670,11 +1670,12 @@ struct type *
lookup_unsigned_typename (const struct language_defn *language,
const char *name)
{
- char *uns = (char *) alloca (strlen (name) + 10);
+ std::string uns;
+ uns.reserve (strlen (name) + strlen ("unsigned "));
+ uns = "unsigned ";
+ uns += name;
- strcpy (uns, "unsigned ");
- strcpy (uns + 9, name);
- return lookup_typename (language, uns, NULL, 0);
+ return lookup_typename (language, uns.c_str (), NULL, 0);
}
struct type *
@@ -1760,16 +1761,14 @@ struct type *
lookup_template_type (const char *name, struct type *type,
const struct block *block)
{
- struct symbol *sym;
- char *nam = (char *)
- alloca (strlen (name) + strlen (type->name ()) + 4);
-
- strcpy (nam, name);
- strcat (nam, "<");
- strcat (nam, type->name ());
- strcat (nam, " >"); /* FIXME, extra space still introduced in gcc? */
+ std::string nam;
+ nam.reserve (strlen (name) + strlen (type->name ()) + strlen ("< >"));
+ nam = name;
+ nam += "<";
+ nam += type->name ();
+ nam += " >"; /* FIXME, extra space still introduced in gcc? */
- sym = lookup_symbol (nam, block, VAR_DOMAIN, 0).symbol;
+ symbol *sym = lookup_symbol (nam.c_str (), block, VAR_DOMAIN, 0).symbol;
if (sym == NULL)
{