From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSDfw-0008JH-VR for qemu-devel@nongnu.org; Thu, 11 Sep 2014 19:21:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XSDfo-0003WF-RC for qemu-devel@nongnu.org; Thu, 11 Sep 2014 19:21:16 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:47456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSDfo-0003W2-HU for qemu-devel@nongnu.org; Thu, 11 Sep 2014 19:21:08 -0400 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 11 Sep 2014 19:21:08 -0400 From: Michael Roth Date: Thu, 11 Sep 2014 18:20:58 -0500 Message-Id: <1410477659-9163-3-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1410477659-9163-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1410477659-9163-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 2/3] qapi: dealloc visitor, implement visit_start_union List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: famz@redhat.com, armbru@redhat.com, qemu-stable@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com If the .data field of a QAPI Union is NULL, we don't need to free any of the union fields.. Make use of the new visit_start_union interface to access this information and instruct the generated code to not visit these fields when this occurs. Cc: qemu-stable@nongnu.org Reported-by: Fam Zheng Suggested-by: Paolo Bonzini Signed-off-by: Michael Roth --- qapi/qapi-dealloc-visitor.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c index dc53545..eb77078 100644 --- a/qapi/qapi-dealloc-visitor.c +++ b/qapi/qapi-dealloc-visitor.c @@ -162,6 +162,11 @@ static void qapi_dealloc_type_enum(Visitor *v, int *obj, const char *strings[], { } +static bool qapi_dealloc_start_union(Visitor *v, bool data_present, Error **errp) +{ + return data_present; +} + Visitor *qapi_dealloc_get_visitor(QapiDeallocVisitor *v) { return &v->visitor; @@ -191,6 +196,7 @@ QapiDeallocVisitor *qapi_dealloc_visitor_new(void) v->visitor.type_str = qapi_dealloc_type_str; v->visitor.type_number = qapi_dealloc_type_number; v->visitor.type_size = qapi_dealloc_type_size; + v->visitor.start_union = qapi_dealloc_start_union; QTAILQ_INIT(&v->stack); -- 1.9.1