[libvirt] Question about VIR_ALLOC vs vshMalloc

Eric Blake eblake at redhat.com
Thu Mar 20 18:50:42 UTC 2014


On 03/20/2014 12:02 PM, Solly Ross wrote:
> I was wondering what the reason was for seemingly near-duplicate code.  VIR_ALLOC and vshMalloc (and similar methods for calloc, etc), seem to be roughly identical in function, with the only difference being that VIR_ALLOC and friends are used in libvirt proper, whereas vshMalloc and friends are used in the virsh code.  Is there a reason why virsh does not simply use VIR_ALLOC and friends?

vshMalloc calls exit() on failure, VIR_ALLOC returns NULL to the caller.
 libvirt.so (anything in src/) cannot call exit, but virsh is an
executable not a library, so exiting is sometimes easier than dealing
with failed allocations.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140320/5cac9ded/attachment-0001.sig>


More information about the libvir-list mailing list