[libvirt PATCH 12/13] conf: use g_new0

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

 



Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/conf/checkpoint_conf.c            |  4 ++--
 src/conf/domain_capabilities.c        |  7 +------
 src/conf/domain_event.c               |  3 +--
 src/conf/domain_nwfilter.c            |  3 +--
 src/conf/netdev_bandwidth_conf.c      |  9 +++------
 src/conf/netdev_vlan_conf.c           |  4 +---
 src/conf/netdev_vport_profile_conf.c  |  3 +--
 src/conf/networkcommon_conf.c         |  3 +--
 src/conf/nwfilter_conf.c              | 12 ++++--------
 src/conf/object_event.c               | 11 +++--------
 src/conf/secret_conf.c                |  3 +--
 src/conf/snapshot_conf.c              |  4 ++--
 src/conf/virchrdev.c                  | 10 +++-------
 src/conf/virdomaincheckpointobjlist.c | 10 +++++-----
 src/conf/virdomainmomentobjlist.c     |  6 ++----
 src/conf/virdomainobjlist.c           |  8 ++------
 src/conf/virdomainsnapshotobjlist.c   |  9 ++++-----
 src/conf/virinterfaceobj.c            |  5 ++---
 src/conf/virnetworkobj.c              |  7 +++----
 src/conf/virnetworkportdef.c          |  4 ++--
 src/conf/virnodedeviceobj.c           |  7 ++-----
 src/conf/virnwfilterbindingdef.c      |  6 ++----
 src/conf/virnwfilterbindingobjlist.c  |  8 ++------
 src/conf/virnwfilterobj.c             |  9 +++------
 24 files changed, 53 insertions(+), 102 deletions(-)

diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c
index f97621dabf..e175917eae 100644
--- a/src/conf/checkpoint_conf.c
+++ b/src/conf/checkpoint_conf.c
@@ -182,8 +182,8 @@ virDomainCheckpointDefParse(xmlXPathContextPtr ctxt,
 
     if ((n = virXPathNodeSet("./disks/*", ctxt, &nodes)) < 0)
         return NULL;
-    if (n && VIR_ALLOC_N(def->disks, n) < 0)
-        return NULL;
+    if (n)
+        def->disks = g_new0(virDomainCheckpointDiskDef, n);
     def->ndisks = n;
     for (i = 0; i < def->ndisks; i++) {
         if (virDomainCheckpointDiskDefParseXML(nodes[i], ctxt,
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 59ad8937a4..6ee8730111 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -155,15 +155,10 @@ virDomainCapsCPUModelsNew(size_t nmodels)
     if (!(cpuModels = virObjectNew(virDomainCapsCPUModelsClass)))
         return NULL;
 
-    if (VIR_ALLOC_N(cpuModels->models, nmodels) < 0)
-        goto error;
+    cpuModels->models = g_new0(virDomainCapsCPUModel, nmodels);
     cpuModels->nmodels_max = nmodels;
 
     return cpuModels;
-
- error:
-    virObjectUnref(cpuModels);
-    return NULL;
 }
 
 
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index d3acde0236..a8bd9f1595 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -2242,8 +2242,7 @@ virDomainQemuMonitorEventStateRegisterID(virConnectPtr conn,
         virCheckFlags(VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX |
                       VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_NOCASE,
                       -1);
-    if (VIR_ALLOC(data) < 0)
-        return -1;
+    data = g_new0(virDomainQemuMonitorEventData, 1);
     data->flags = flags;
     if (event && flags != -1) {
         if (flags & VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX) {
diff --git a/src/conf/domain_nwfilter.c b/src/conf/domain_nwfilter.c
index a72db6f876..ef388d5d02 100644
--- a/src/conf/domain_nwfilter.c
+++ b/src/conf/domain_nwfilter.c
@@ -44,8 +44,7 @@ virNWFilterBindingDefForNet(const char *vmname,
 {
     virNWFilterBindingDefPtr ret;
 
-    if (VIR_ALLOC(ret) < 0)
-        return NULL;
+    ret = g_new0(virNWFilterBindingDef, 1);
 
     ret->ownername = g_strdup(vmname);
 
diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_conf.c
index 396ac62019..831ee036ac 100644
--- a/src/conf/netdev_bandwidth_conf.c
+++ b/src/conf/netdev_bandwidth_conf.c
@@ -121,8 +121,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
     xmlNodePtr in = NULL, out = NULL;
     char *class_id_prop = NULL;
 
-    if (VIR_ALLOC(def) < 0)
-        return ret;
+    def = g_new0(virNetDevBandwidth, 1);
 
     if (!node || !virXMLNodeNameEqual(node, "bandwidth")) {
         virReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -173,8 +172,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
     }
 
     if (in) {
-        if (VIR_ALLOC(def->in) < 0)
-            goto cleanup;
+        def->in = g_new0(virNetDevBandwidthRate, 1);
 
         if (virNetDevBandwidthParseRate(in, def->in) < 0) {
             /* helper reported error for us */
@@ -189,8 +187,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
     }
 
     if (out) {
-        if (VIR_ALLOC(def->out) < 0)
-            goto cleanup;
+        def->out = g_new0(virNetDevBandwidthRate, 1);
 
         if (virNetDevBandwidthParseRate(out, def->out) < 0) {
             /* helper reported error for us */
diff --git a/src/conf/netdev_vlan_conf.c b/src/conf/netdev_vlan_conf.c
index 493708fee1..6c93279ec5 100644
--- a/src/conf/netdev_vlan_conf.c
+++ b/src/conf/netdev_vlan_conf.c
@@ -53,9 +53,7 @@ virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr ctxt, virNetDevVlanPtr de
         goto cleanup;
     }
 
-    if (VIR_ALLOC_N(def->tag, nTags) < 0)
-        goto cleanup;
-
+    def->tag = g_new0(unsigned int, nTags);
     def->nativeMode = 0;
     def->nativeTag = 0;
     for (i = 0; i < nTags; i++) {
diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_profile_conf.c
index 1dd8439adb..fdc689b38a 100644
--- a/src/conf/netdev_vport_profile_conf.c
+++ b/src/conf/netdev_vport_profile_conf.c
@@ -39,8 +39,7 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
     virNetDevVPortProfilePtr virtPort = NULL;
     xmlNodePtr cur = node->children;
 
-    if (VIR_ALLOC(virtPort) < 0)
-        return NULL;
+    virtPort = g_new0(virNetDevVPortProfile, 1);
 
     if ((virtPortType = virXMLPropString(node, "type")) &&
         (virtPort->virtPortType = virNetDevVPortTypeFromString(virtPortType)) <= 0) {
diff --git a/src/conf/networkcommon_conf.c b/src/conf/networkcommon_conf.c
index 2e51c80174..26eeb6dbda 100644
--- a/src/conf/networkcommon_conf.c
+++ b/src/conf/networkcommon_conf.c
@@ -44,8 +44,7 @@ virNetDevIPRouteCreate(const char *errorDetail,
     virNetDevIPRoutePtr def = NULL;
     virSocketAddr testAddr;
 
-    if (VIR_ALLOC(def) < 0)
-        return NULL;
+    def = g_new0(virNetDevIPRoute, 1);
 
     def->family = g_strdup(family);
 
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 53794e8f6d..be684c3512 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2069,8 +2069,7 @@ virNWFilterIncludeParse(xmlNodePtr cur)
 {
     virNWFilterIncludeDefPtr ret;
 
-    if (VIR_ALLOC(ret) < 0)
-        return NULL;
+    ret = g_new0(virNWFilterIncludeDef, 1);
 
     ret->filterref = virXMLPropString(cur, "filter");
     if (!ret->filterref) {
@@ -2423,8 +2422,7 @@ virNWFilterRuleParse(xmlNodePtr node)
     xmlNodePtr cur;
     virNWFilterRuleDefPtr ret;
 
-    if (VIR_ALLOC(ret) < 0)
-        return NULL;
+    ret = g_new0(virNWFilterRuleDef, 1);
 
     action     = virXMLPropString(node, "action");
     direction  = virXMLPropString(node, "direction");
@@ -2616,8 +2614,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt)
     int chain_priority;
     const char *name_prefix;
 
-    if (VIR_ALLOC(ret) < 0)
-        return NULL;
+    ret = g_new0(virNWFilterDef, 1);
 
     ret->name = virXPathString("string(./@name)", ctxt);
     if (!ret->name) {
@@ -2689,8 +2686,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt)
 
     while (curr != NULL) {
         if (curr->type == XML_ELEMENT_NODE) {
-            if (VIR_ALLOC(entry) < 0)
-                goto cleanup;
+            entry = g_new0(virNWFilterEntry, 1);
 
             if (virXMLNodeNameEqual(curr, "rule")) {
                 if (!(entry->rule = virNWFilterRuleParse(curr))) {
diff --git a/src/conf/object_event.c b/src/conf/object_event.c
index 408e0fd2b2..28e75f8b59 100644
--- a/src/conf/object_event.c
+++ b/src/conf/object_event.c
@@ -424,8 +424,7 @@ virObjectEventCallbackListAddID(virConnectPtr conn,
         return -1;
     }
     /* Allocate new cb */
-    if (VIR_ALLOC(cb) < 0)
-        goto cleanup;
+    cb = g_new0(virObjectEventCallback, 1);
     cb->conn = virObjectRef(conn);
     *callbackID = cb->callbackID = cbList->nextID++;
     cb->cb = callback;
@@ -501,10 +500,7 @@ virObjectEventQueueFree(virObjectEventQueuePtr queue)
 static virObjectEventQueuePtr
 virObjectEventQueueNew(void)
 {
-    virObjectEventQueuePtr ret;
-
-    ignore_value(VIR_ALLOC(ret));
-    return ret;
+    return g_new0(virObjectEventQueue, 1);
 }
 
 
@@ -566,8 +562,7 @@ virObjectEventStateNew(void)
     if (!(state = virObjectLockableNew(virObjectEventStateClass)))
         return NULL;
 
-    if (VIR_ALLOC(state->callbacks) < 0)
-        goto error;
+    state->callbacks = g_new0(virObjectEventCallbackList, 1);
 
     if (!(state->queue = virObjectEventQueueNew()))
         goto error;
diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c
index 2e35348ce1..273987bdb4 100644
--- a/src/conf/secret_conf.c
+++ b/src/conf/secret_conf.c
@@ -149,8 +149,7 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root)
 
     ctxt->node = root;
 
-    if (VIR_ALLOC(def) < 0)
-        return NULL;
+    def = g_new0(virSecretDef, 1);
 
     prop = virXPathString("string(./@ephemeral)", ctxt);
     if (prop != NULL) {
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 7090e3a1b0..31cce15d53 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -367,8 +367,8 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
     if ((n = virXPathNodeSet("./disks/*", ctxt, &nodes)) < 0)
         goto cleanup;
     if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_DISKS) {
-        if (n && VIR_ALLOC_N(def->disks, n) < 0)
-            goto cleanup;
+        if (n)
+            def->disks = g_new0(virDomainSnapshotDiskDef, n);
         def->ndisks = n;
         for (i = 0; i < def->ndisks; i++) {
             if (virDomainSnapshotDiskDefParseXML(nodes[i], ctxt, &def->disks[i],
diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c
index 635aa43c49..c50f9ca720 100644
--- a/src/conf/virchrdev.c
+++ b/src/conf/virchrdev.c
@@ -255,8 +255,7 @@ static void virChrdevFDStreamCloseCb(virStreamPtr st G_GNUC_UNUSED,
 virChrdevsPtr virChrdevAlloc(void)
 {
     virChrdevsPtr devs;
-    if (VIR_ALLOC(devs) < 0)
-        return NULL;
+    devs = g_new0(virChrdevs, 1);
 
     if (virMutexInit(&devs->lock) < 0) {
         virReportSystemError(errno, "%s",
@@ -388,11 +387,8 @@ int virChrdevOpen(virChrdevsPtr devs,
         return -1;
     }
 
-    if (VIR_ALLOC(cbdata) < 0)
-        goto error;
-
-    if (VIR_ALLOC(ent) < 0)
-        goto error;
+    cbdata = g_new0(virChrdevStreamInfo, 1);
+    ent = g_new0(virChrdevHashEntry, 1);
 
     ent->st = st;
     ent->dev = g_strdup(path);
diff --git a/src/conf/virdomaincheckpointobjlist.c b/src/conf/virdomaincheckpointobjlist.c
index a4942ea706..c6f2fbe46f 100644
--- a/src/conf/virdomaincheckpointobjlist.c
+++ b/src/conf/virdomaincheckpointobjlist.c
@@ -62,8 +62,8 @@ virDomainCheckpointObjListNew(void)
 {
     virDomainCheckpointObjListPtr checkpoints;
 
-    if (VIR_ALLOC(checkpoints) < 0)
-        return NULL;
+    checkpoints = g_new0(virDomainCheckpointObjList,
+                         1);
     checkpoints->base = virDomainMomentObjListNew();
     if (!checkpoints->base) {
         VIR_FREE(checkpoints);
@@ -216,9 +216,9 @@ virDomainListCheckpoints(virDomainCheckpointObjListPtr checkpoints,
 
     if (!chks || count < 0)
         return count;
-    if (VIR_ALLOC_N(names, count) < 0 ||
-        VIR_ALLOC_N(list, count + 1) < 0)
-        goto cleanup;
+
+    names = g_new0(char *, count);
+    list = g_new0(virDomainCheckpointPtr, count + 1);
 
     if (virDomainCheckpointObjListGetNames(checkpoints, from, names, count,
                                            flags) < 0)
diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentobjlist.c
index 18dbd434fb..8a1eb6b734 100644
--- a/src/conf/virdomainmomentobjlist.c
+++ b/src/conf/virdomainmomentobjlist.c
@@ -212,8 +212,7 @@ virDomainMomentObjNew(void)
 {
     virDomainMomentObjPtr moment;
 
-    if (VIR_ALLOC(moment) < 0)
-        return NULL;
+    moment = g_new0(virDomainMomentObj, 1);
 
     VIR_DEBUG("obj=%p", moment);
 
@@ -275,8 +274,7 @@ virDomainMomentObjListNew(void)
 {
     virDomainMomentObjListPtr moments;
 
-    if (VIR_ALLOC(moments) < 0)
-        return NULL;
+    moments = g_new0(virDomainMomentObjList, 1);
     moments->objs = virHashCreate(50, virDomainMomentObjListDataFree);
     if (!moments->objs) {
         VIR_FREE(moments);
diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index 417025ae9f..46b28cc9a6 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -981,10 +981,7 @@ virDomainObjListCollect(virDomainObjListPtr domlist,
 
     virObjectRWLockRead(domlist);
     sa_assert(domlist->objs);
-    if (VIR_ALLOC_N(data.vms, virHashSize(domlist->objs)) < 0) {
-        virObjectRWUnlock(domlist);
-        return -1;
-    }
+    data.vms = g_new0(virDomainObjPtr, virHashSize(domlist->objs));
 
     virHashForEach(domlist->objs, virDomainObjListCollectIterator, &data);
     virObjectRWUnlock(domlist);
@@ -1074,8 +1071,7 @@ virDomainObjListExport(virDomainObjListPtr domlist,
         return -1;
 
     if (domains) {
-        if (VIR_ALLOC_N(doms, nvms + 1) < 0)
-            goto cleanup;
+        doms = g_new0(virDomainPtr, nvms + 1);
 
         for (i = 0; i < nvms; i++) {
             virDomainObjPtr vm = vms[i];
diff --git a/src/conf/virdomainsnapshotobjlist.c b/src/conf/virdomainsnapshotobjlist.c
index 910b0714c7..f13150e463 100644
--- a/src/conf/virdomainsnapshotobjlist.c
+++ b/src/conf/virdomainsnapshotobjlist.c
@@ -85,8 +85,8 @@ virDomainSnapshotObjListNew(void)
 {
     virDomainSnapshotObjListPtr snapshots;
 
-    if (VIR_ALLOC(snapshots) < 0)
-        return NULL;
+    snapshots = g_new0(virDomainSnapshotObjList,
+                       1);
     snapshots->base = virDomainMomentObjListNew();
     if (!snapshots->base) {
         VIR_FREE(snapshots);
@@ -267,9 +267,8 @@ virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots,
 
     if (!snaps || count < 0)
         return count;
-    if (VIR_ALLOC_N(names, count) < 0 ||
-        VIR_ALLOC_N(list, count + 1) < 0)
-        goto cleanup;
+    names = g_new0(char *, count);
+    list = g_new0(virDomainSnapshotPtr, count + 1);
 
     if (virDomainSnapshotObjListGetNames(snapshots, from, names, count,
                                          flags) < 0)
diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c
index 43ba395d2b..5a5fd65e14 100644
--- a/src/conf/virinterfaceobj.c
+++ b/src/conf/virinterfaceobj.c
@@ -319,9 +319,8 @@ virInterfaceObjListExport(virConnectPtr conn,
         .nifaces = 0, .error = false };
 
     virObjectRWLockRead(ifaceobjs);
-    if (ifaces && VIR_ALLOC_N(data.ifaces,
-                              virHashSize(ifaceobjs->objsName) + 1) < 0)
-        goto cleanup;
+    if (ifaces)
+        data.ifaces = g_new0(virInterfacePtr, virHashSize(ifaceobjs->objsName));
 
     virHashForEach(ifaceobjs->objsName, virInterfaceObjListExportCallback, &data);
 
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index aefe23fde1..1fcfa9cdc2 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -1406,8 +1406,8 @@ virNetworkObjListExport(virConnectPtr conn,
         .nnets = 0, .error = false };
 
     virObjectRWLockRead(netobjs);
-    if (nets && VIR_ALLOC_N(data.nets, virHashSize(netobjs->objs) + 1) < 0)
-        goto cleanup;
+    if (nets)
+        data.nets = g_new0(virNetworkPtr, virHashSize(netobjs->objs));
 
     virHashForEach(netobjs->objs, virNetworkObjListExportCallback, &data);
 
@@ -1801,8 +1801,7 @@ virNetworkObjPortListExport(virNetworkPtr net,
     if (ports) {
         *ports = NULL;
 
-        if (VIR_ALLOC_N(data.ports, virHashSize(obj->ports) + 1) < 0)
-            goto cleanup;
+        data.ports = g_new0(virNetworkPortPtr, virHashSize(obj->ports));
     }
 
     virHashForEach(obj->ports, virNetworkObjPortListExportCallback, &data);
diff --git a/src/conf/virnetworkportdef.c b/src/conf/virnetworkportdef.c
index 1db3dc69e2..3183078195 100644
--- a/src/conf/virnetworkportdef.c
+++ b/src/conf/virnetworkportdef.c
@@ -95,8 +95,8 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt)
     g_autofree char *managed = NULL;
     g_autofree char *driver = NULL;
 
-    if (VIR_ALLOC(def) < 0)
-        return NULL;
+    def = g_new0(virNetworkPortDef,
+                 1);
 
     uuid = virXPathString("string(./uuid)", ctxt);
     if (!uuid) {
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index 8aefd15e94..28905c67b6 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -930,11 +930,8 @@ virNodeDeviceObjListExport(virConnectPtr conn,
         .devices = NULL, .ndevices = 0, .error = false };
 
     virObjectRWLockRead(devs);
-    if (devices &&
-        VIR_ALLOC_N(data.devices, virHashSize(devs->objs) + 1) < 0) {
-        virObjectRWUnlock(devs);
-        return -1;
-    }
+    if (devices)
+        data.devices = g_new0(virNodeDevicePtr, virHashSize(devs->objs));
 
     virHashForEach(devs->objs, virNodeDeviceObjListExportCallback, &data);
     virObjectRWUnlock(devs);
diff --git a/src/conf/virnwfilterbindingdef.c b/src/conf/virnwfilterbindingdef.c
index f286bdd840..81f8e72182 100644
--- a/src/conf/virnwfilterbindingdef.c
+++ b/src/conf/virnwfilterbindingdef.c
@@ -51,8 +51,7 @@ virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src)
 {
     virNWFilterBindingDefPtr ret;
 
-    if (VIR_ALLOC(ret) < 0)
-        return NULL;
+    ret = g_new0(virNWFilterBindingDef, 1);
 
     ret->ownername = g_strdup(src->ownername);
 
@@ -88,8 +87,7 @@ virNWFilterBindingDefParseXML(xmlXPathContextPtr ctxt)
     char *mac = NULL;
     xmlNodePtr node;
 
-    if (VIR_ALLOC(ret) < 0)
-        return NULL;
+    ret = g_new0(virNWFilterBindingDef, 1);
 
     ret->portdevname = virXPathString("string(./portdev/@name)", ctxt);
     if (!ret->portdevname) {
diff --git a/src/conf/virnwfilterbindingobjlist.c b/src/conf/virnwfilterbindingobjlist.c
index 97e4d3c49b..328b1b8482 100644
--- a/src/conf/virnwfilterbindingobjlist.c
+++ b/src/conf/virnwfilterbindingobjlist.c
@@ -434,10 +434,7 @@ virNWFilterBindingObjListCollect(virNWFilterBindingObjListPtr domlist,
 
     virObjectRWLockRead(domlist);
     sa_assert(domlist->objs);
-    if (VIR_ALLOC_N(data.bindings, virHashSize(domlist->objs)) < 0) {
-        virObjectRWUnlock(domlist);
-        return -1;
-    }
+    data.bindings = g_new0(virNWFilterBindingObjPtr, virHashSize(domlist->objs));
 
     virHashForEach(domlist->objs, virNWFilterBindingObjListCollectIterator, &data);
     virObjectRWUnlock(domlist);
@@ -467,8 +464,7 @@ virNWFilterBindingObjListExport(virNWFilterBindingObjListPtr bindings,
         return -1;
 
     if (bindinglist) {
-        if (VIR_ALLOC_N(*bindinglist, nbindings + 1) < 0)
-            goto cleanup;
+        *bindinglist = g_new0(virNWFilterBindingPtr, nbindings + 1);
 
         for (i = 0; i < nbindings; i++) {
             virNWFilterBindingObjPtr binding = bindingobjs[i];
diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c
index c9e224061d..fce402f907 100644
--- a/src/conf/virnwfilterobj.c
+++ b/src/conf/virnwfilterobj.c
@@ -53,8 +53,7 @@ virNWFilterObjNew(void)
 {
     virNWFilterObjPtr obj;
 
-    if (VIR_ALLOC(obj) < 0)
-        return NULL;
+    obj = g_new0(virNWFilterObj, 1);
 
     if (virMutexInitRecursive(&obj->lock) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -120,8 +119,7 @@ virNWFilterObjListNew(void)
 {
     virNWFilterObjListPtr nwfilters;
 
-    if (VIR_ALLOC(nwfilters) < 0)
-        return NULL;
+    nwfilters = g_new0(virNWFilterObjList, 1);
     return nwfilters;
 }
 
@@ -450,8 +448,7 @@ virNWFilterObjListExport(virConnectPtr conn,
         goto cleanup;
     }
 
-    if (VIR_ALLOC_N(tmp_filters, nwfilters->count + 1) < 0)
-        goto cleanup;
+    tmp_filters = g_new0(virNWFilterPtr, nwfilters->count + 1);
 
     for (i = 0; i < nwfilters->count; i++) {
         obj = nwfilters->objs[i];
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux