[Top][All Lists]
[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
- [Qemu-devel] [PULL] QAPI code generator fix-ups, Michael Roth, 2011/04/29
- [Qemu-devel] [PATCH 2/9] qapi: input visiter, don't always allocate memory for structs,
Michael Roth <=
- [Qemu-devel] [PATCH 3/9] qapi: Fix visiter generator for nested structs/qobjects, Michael Roth, 2011/04/29
- [Qemu-devel] [PATCH 1/9] qapi: Fix type generator for structured type members, Michael Roth, 2011/04/29
- [Qemu-devel] [PATCH 4/9] qapi: some basename/guardname py utility functions, Michael Roth, 2011/04/29
- [Qemu-devel] [PATCH 5/9] qapi: add --prefix option to type generator, Michael Roth, 2011/04/29
- [Qemu-devel] [PATCH 6/9] qapi: add --prefix option for visiter generator, Michael Roth, 2011/04/29
- [Qemu-devel] [PATCH 7/9] qapi: test schema for test-visiter unit tests, Michael Roth, 2011/04/29
- [Qemu-devel] [PATCH 8/9] qapi: Makefile, build test-visiter with generated test code, Michael Roth, 2011/04/29
- [Qemu-devel] [PATCH 9/9] qapi: test-visiter, pull in gen code, tests for nested structures, Michael Roth, 2011/04/29