qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 07/18] qom: add link properties


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 07/18] qom: add link properties
Date: Thu, 01 Dec 2011 08:56:25 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Lightning/1.0b2 Thunderbird/3.1.13

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






reply via email to

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