[libvirt] [PATCH 2/3] xml: add another convenience function
Eric Blake
eblake at redhat.com
Fri Aug 19 15:16:51 UTC 2011
On 08/19/2011 02:48 AM, Daniel Veillard wrote:
>> + * Return the parsed document object, or NULL on failure.
>> + */
>> +# define virXMLParseFileCtxt(filename, pctxt) \
>> + virXMLParseHelper(VIR_FROM_THIS, filename, NULL, NULL, pctxt)
>>
>> #endif /* __VIR_XML_H__ */
>
> ACK to the overall cleanup, I'm just a bit dubious about
> xmlXPathContextPtr initialization in the helper, as I like to have
> allocations and frees matched to the same level. It's easier to forget
> to free the context if one doesn't "see" it allocated. But it's a minor
> concern.
I think you can still "see" the allocations - it's just that virXMLParse
does one allocation (return value), while virXMLParseCtxt does two
allocations (return value, and allocation into passed pointer). Yes, it
does mean that one virXMLParseCtxt call results in two separate free
calls, but hopefully we don't introduce leaks because of it, and coding
by copy-paste should still work at cleaning both variables.
At any rate, I've now pushed the series.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
More information about the libvir-list
mailing list