[libvirt] [PATCH 09/10] conf: Provide missing virDomain*DefNew() functions

Andrea Bolognani abologna at redhat.com
Fri Jun 30 10:34:15 UTC 2017

On Fri, 2017-06-30 at 10:18 +0200, Ján Tomko wrote:
> > Same as virDomainDeviceInfo itself, any struct that
> > embeds it needs to be initialized properly before use;
> > however, none of the structs in question even had a
> > proper allocation function defined.
>> > Implement an allocation function for all structs
> > embedding a virDomainDeviceInfo and use them instead
> > of plain VIR_ALLOC() everywhere.
> This is a pointless obfuscation

Would you mind spending a few words to explain why you feel
that's the case?

Having a function where you perform both allocation and
initialization of your data structure is a pretty common
pattern both outside and inside libvirt, and while it adds
one layer of indirection it also improves flexibility and
encapsulation, which makes it IMHO well worth it.

Andrea Bolognani / Red Hat / Virtualization

More information about the libvir-list mailing list