qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/5] gdbstub: Replace alloca() by g_new()


From: Philippe Mathieu-Daudé
Subject: [PATCH 4/5] gdbstub: Replace alloca() by g_new()
Date: Wed, 5 May 2021 19:00:54 +0200

The ALLOCA(3) man-page mentions its "use is discouraged".

Replace it by a g_new() call.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 gdbstub.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gdbstub.c b/gdbstub.c
index 0d5569ee539..72b4be89c7b 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1475,7 +1475,9 @@ static int process_string_cmd(void *user_ctx, const char 
*data,
                               const GdbCmdParseEntry *cmds, int num_cmds)
 {
     int i, schema_len, max_num_params = 0;
-    GdbCmdContext gdb_ctx;
+    g_autofree GdbCmdVariant *params = g_new(GdbCmdVariant,
+                                        GDB_CMD_PARSE_ENTRY_SCHEMA_SIZE / 2);
+    GdbCmdContext gdb_ctx = { .params = params };
 
     if (!cmds) {
         return -1;
@@ -1499,8 +1501,6 @@ static int process_string_cmd(void *user_ctx, const char 
*data,
             max_num_params = schema_len / 2;
         }
 
-        gdb_ctx.params =
-            (GdbCmdVariant *)alloca(sizeof(*gdb_ctx.params) * max_num_params);
         memset(gdb_ctx.params, 0, sizeof(*gdb_ctx.params) * max_num_params);
 
         if (cmd_parse_params(&data[strlen(cmd->cmd)], cmd->schema,
-- 
2.26.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]