Re: [PATCH 5/5] don't check for NULL before calling virHashFree

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

 



On 02/18/2011 12:30 PM, Jim Meyering wrote:
>>> -    if (doms->objs)
>>> -        virHashFree(doms->objs, virDomainObjListDeallocator);
>>> +    virHashFree(doms->objs, virDomainObjListDeallocator);
>>
>> I tried adding --name=virHashFree to the useless_free_options variable
>> in cfg.mk, to see if that would prevent regressions.  However, it
>> appears that this two-argument free-like function is not picked up by
>> the heuristics in the useless-if-before-free script (it only works on
>> one-argument functions).

> Right.  useless-if-before-free deliberately detects only
> one-argument free-like functions.

An even better idea - as long as we're improving hash.h, why not fix
things to pass the destructor in the Create call, rather than the Free
call.  Then freeing is a one-argument operation, using the destructor
callback registered inside the virHash object, rather than a
two-argument operation requiring the caller to pass in the destructor.
At which point, we've defined away the problem of useless-if-before-free.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]