From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFpXe-00035n-50 for qemu-devel@nongnu.org; Fri, 29 Apr 2011 11:23:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QFpXc-0006Q4-V2 for qemu-devel@nongnu.org; Fri, 29 Apr 2011 11:23:38 -0400 Received: from mout.perfora.net ([74.208.4.194]:58277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFpXc-0006Pz-PR for qemu-devel@nongnu.org; Fri, 29 Apr 2011 11:23:36 -0400 From: Michael Roth Date: Fri, 29 Apr 2011 10:21:55 -0500 Message-Id: <1304090522-5861-3-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1304090522-5861-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1304090522-5861-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 2/9] qapi: input visiter, don't always allocate memory for structs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@linux.vnet.ibm.com, agl@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com 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 --- 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