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

[libvirt] [PATCH 05/20] Allow caps to be NULL when creating virDomainObjPtr instances



From: "Daniel P. Berrange" <berrange redhat com>

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 <berrange redhat com>
---
 src/conf/domain_conf.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8952b69..ef368f7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1716,12 +1716,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;
-- 
1.7.11.4


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