On 08/27/2013 06:11 AM, Michal Privoznik wrote:
> All _internal_ vir*Free functions should be NOPs. All public
vir*Free
> APIs (including virNetworkFree) are documented to explicitly fail on
> NULL arguments (more precisely, on any argument not created by an
> earlier API call), and we cannot change that behavior as it would be an
> API change that violates back-compat.
Why it would break backward compatibility? I think it will break forward
compatibility instead (which we don't care about). That is, currently
apps have to use:
virXPtr obj = NULL;
obj = virLookupBy..();
... do something with obj;
ret = 0;
cleanup:
if (obj)
virXFree(obj);
However, if virXFree would accept NULL, it won't affect older
applications, while new can just:
cleanup:
virXFree(obj);
But then again, this is forward compatibility (the code won't work with
downgraded libvirtd) - but who cares?
Back-compat says because we documented it, a user can expect:
virXFree(NULL);
to raise an error. If we change things so that it no longer raises an
error, then their code that was expecting an error may misbehave because
it now goes into code paths that were not previously present.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org