return 0;
}
-void virDomainChrSourceDefFree(virDomainChrSourceDefPtr def)
+static void
+virDomainChrSourceDefDispose(void *obj)
{
+ virDomainChrSourceDefPtr def = obj;
size_t i;
if (!def)
virSecurityDeviceLabelDefFree(def->seclabels[i]);
VIR_FREE(def->seclabels);
}
+}
- VIR_FREE(def);
+void
+virDomainChrSourceDefFree(virDomainChrSourceDefPtr def)
+{
+ virObjectUnref(def);
}
+
/* virDomainChrSourceDefIsEqual:
* @src: Source
* @tgt: Target
}
+static virClassPtr virDomainChrSourceDefClass;
+
+static int
+virDomainChrSourceDefOnceInit(void)
+{
+ virDomainChrSourceDefClass = virClassNew(virClassForObject(),
+ "virDomainChrSourceDef",
+ sizeof(virDomainChrSourceDef),
+ virDomainChrSourceDefDispose);
+ if (!virDomainChrSourceDefClass)
+ return -1;
+ else
+ return 0;
+}
+
+VIR_ONCE_GLOBAL_INIT(virDomainChrSourceDef);
+
virDomainChrSourceDefPtr
virDomainChrSourceDefNew(virDomainXMLOptionPtr xmlopt)
{
virDomainChrSourceDefPtr def = NULL;
- if (VIR_ALLOC(def) < 0)
+ if (virDomainChrSourceDefInitialize() < 0)
+ return NULL;
+
+ if (!(def = virObjectNew(virDomainChrSourceDefClass)))
return NULL;
if (xmlopt && xmlopt->privateData.chrSourceNew &&
- !(def->privateData = xmlopt->privateData.chrSourceNew()))
- VIR_FREE(def);
+ !(def->privateData = xmlopt->privateData.chrSourceNew())) {
+ virObjectUnref(def);
+ def = NULL;
+ }
return def;
}