Patchwork [21/29] monitor: Drop str_allocated[]

login
register
mail settings
Submitter Luiz Capitulino
Date Aug. 13, 2009, 1:50 p.m.
Message ID <1250171428-29308-22-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/31322/
State Superseded
Headers show

Comments

Luiz Capitulino - Aug. 13, 2009, 1:50 p.m.
It's not used anymore, as QDict is now used to handle string
memory allocation/deallocation.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)

Patch

diff --git a/monitor.c b/monitor.c
index c56124b..f4b3872 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2641,7 +2641,6 @@  static int default_fmt_size = 4;
 
 static const mon_cmd_t *monitor_parse_command(Monitor *mon,
                                               const char *cmdline,
-                                              void *str_allocated[],
                                               QDict *qdict)
 {
     const char *p, *typestr;
@@ -2718,7 +2717,6 @@  static const mon_cmd_t *monitor_parse_command(Monitor *mon,
                 }
                 str = qemu_malloc(strlen(buf) + 1);
                 pstrcpy(str, sizeof(buf), buf);
-                str_allocated[nb_args] = str;
             add_str:
                 if (nb_args >= MAX_ARGS) {
                 error_args:
@@ -2728,6 +2726,7 @@  static const mon_cmd_t *monitor_parse_command(Monitor *mon,
                 args[nb_args++] = str;
                 if (str)
                     qdict_add_qstring(qdict, key, qstring_from_str(str));
+                qemu_free(str);
             }
             break;
         case '/':
@@ -2925,17 +2924,12 @@  fail:
 
 static void monitor_handle_command(Monitor *mon, const char *cmdline)
 {
-    int i;
     QDict *qdict;
     const mon_cmd_t *cmd;
-    void *str_allocated[MAX_ARGS];
 
     qdict = qdict_new();
 
-    for (i = 0; i < MAX_ARGS; i++)
-        str_allocated[i] = NULL;
-
-    cmd = monitor_parse_command(mon, cmdline, str_allocated, qdict);
+    cmd = monitor_parse_command(mon, cmdline, qdict);
     if (cmd) {
         void (*handler)(Monitor *mon, const QDict *qdict);
         handler = cmd->handler;
@@ -2943,9 +2937,6 @@  static void monitor_handle_command(Monitor *mon, const char *cmdline)
     }
 
     qobject_decref(QOBJECT(qdict));
-
-    for (i = 0; i < MAX_ARGS; i++)
-        qemu_free(str_allocated[i]);
 }
 
 static void cmd_completion(const char *name, const char *list)