qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 2/9] qapi: input visiter, don't always allocate memo


From: Michael Roth
Subject: [Qemu-devel] [PATCH 2/9] qapi: input visiter, don't always allocate memory for structs
Date: Fri, 29 Apr 2011 10:21:55 -0500

Sometimes we have anonymous nested structs rather than references. In
these cases we call visit_start_struct() primarilly to push the nested
qobject onto the stack, and specify a NULL obj value to avoid doing any
memory allocation. So add a simple check for this NULL value.

Signed-off-by: Michael Roth <address@hidden>
---
 qapi/qmp-input-visiter.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/qapi/qmp-input-visiter.c b/qapi/qmp-input-visiter.c
index 53379fd..4bae85e 100644
--- a/qapi/qmp-input-visiter.c
+++ b/qapi/qmp-input-visiter.c
@@ -75,7 +75,9 @@ static void qmp_input_start_struct(Visiter *v, void **obj, 
const char *kind, con
 
     qmp_input_push(qiv, qobj);
 
-    *obj = qemu_mallocz(QAPI_OBJECT_SIZE);
+    if (obj) {
+        *obj = qemu_mallocz(QAPI_OBJECT_SIZE);
+    }
 }
 
 static void qmp_input_end_struct(Visiter *v, Error **errp)
-- 
1.7.0.4




reply via email to

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