From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:33419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RW849-0005lB-Ll for qemu-devel@nongnu.org; Thu, 01 Dec 2011 09:56:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RW843-0006EG-Qp for qemu-devel@nongnu.org; Thu, 01 Dec 2011 09:56:49 -0500 Received: from e36.co.us.ibm.com ([32.97.110.154]:54632) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RW843-0006E8-KS for qemu-devel@nongnu.org; Thu, 01 Dec 2011 09:56:43 -0500 Received: from /spool/local by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 1 Dec 2011 07:56:42 -0700 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pB1EuRqE112352 for ; Thu, 1 Dec 2011 07:56:34 -0700 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pB1EuQrD012998 for ; Thu, 1 Dec 2011 07:56:27 -0700 Message-ID: <4ED79599.9000401@us.ibm.com> Date: Thu, 01 Dec 2011 08:56:25 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1322687028-29714-1-git-send-email-aliguori@us.ibm.com> <1322687028-29714-8-git-send-email-aliguori@us.ibm.com> <4ED76325.6080305@redhat.com> <4ED7744D.1080306@redhat.com> <4ED78573.508@codemonkey.ws> <4ED78642.6040208@redhat.com> In-Reply-To: <4ED78642.6040208@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 07/18] qom: add link properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Kevin Wolf , Peter Maydell , Stefan Hajnoczi , Stefan Hajnoczi , qemu-devel@nongnu.org, Markus Armbruster , Jan Kiszka , Luiz Capitulino , Michael Roth On 12/01/2011 07:50 AM, Avi Kivity wrote: > On 12/01/2011 03:47 PM, Anthony Liguori wrote: >>> What if it's called with the output visitor? (warning: confusing >>> convention). >> >> The reason there's a single Visitor type that works for both input and >> output visitors is to make it so you can write a single visit function >> that works for input and output. This works very well for most cases >> (in fact, QAPI makes heavy use of it). >> >> That said, I'm starting to feel like there should be a separate input >> and output visitor interface. It would make a number of things (like >> visiting lists) significantly simpler. > > Perhaps. But that's independent of the issue here. No matter how many > visitors you have, you never change a gchar in a string in place, you > always allocate a new string (or you can't change the string length). > So the type needs to be const gchar **, not gchar **. While you are correct, I tend to use 'gchar *' and 'const gchar *' to indicate ownership. If you have a function that takes a 'const gchar **', the expectation is that you wouldn't have to free the return value since g_free() takes a non-const pointer. You would, in fact, have to cast away the const in order to even call free. IOW, if you call visit_type_str() and it returns a newly allocated string to you, it's your responsibility to free it. Regards, Anthony Liguori >