From: Daniel P. Berrange Date: Thu, 6 Sep 2012 15:32:45 +0000 (+0100) Subject: Allow caps to be NULL when creating virDomainObjPtr instances X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=f4780c12dc17fa356905d1651715518c122d1be3;p=people%2Fliuw%2Flibxenctrl-split%2Flibvirt.git Allow caps to be NULL when creating virDomainObjPtr instances If no private data needs to be maintained, it can be useful to create virDomainObjPtr instances without having a virCapsPtr instance around. Adapt the virDomainObjNew() function to allow for a NULL caps Signed-off-by: Daniel P. Berrange --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3b44f0c27..2f8e5d258 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1732,12 +1732,14 @@ virDomainObjPtr virDomainObjNew(virCapsPtr caps) return NULL; } - if (caps->privateDataAllocFunc && - !(domain->privateData = (caps->privateDataAllocFunc)())) { - virReportOOMError(); - goto error; + if (caps && + caps->privateDataAllocFunc) { + if (!(domain->privateData = (caps->privateDataAllocFunc)())) { + virReportOOMError(); + goto error; + } + domain->privateDataFreeFunc = caps->privateDataFreeFunc; } - domain->privateDataFreeFunc = caps->privateDataFreeFunc; if (!(domain->snapshots = virDomainSnapshotObjListNew())) goto error;