}
/* Allocate per-connection private data */
- if (VIR_ALLOC(priv) < 0)
- goto cleanup;
+ priv = g_new0(esxPrivate, 1);
if (esxUtil_ParseUri(&priv->parsedUri, conn->uri) < 0)
goto cleanup;
!MATCH(VIR_CONNECT_LIST_DOMAINS_PERSISTENT)) ||
(MATCH(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE) &&
!MATCH(VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE))) {
- if (domains &&
- VIR_ALLOC_N(*domains, 1) < 0)
- goto cleanup;
+ if (domains)
+ *domains = g_new0(virDomainPtr, 1);
ret = 0;
goto cleanup;
goto cleanup;
if (domains) {
- if (VIR_ALLOC_N(doms, 1) < 0)
- goto cleanup;
+ doms = g_new0(virDomainPtr, 1);
ndoms = 1;
}
if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0)
goto cleanup;
- if (VIR_ALLOC(ifaces_ret[ifaces_count - 1]) < 0)
- goto cleanup;
+ ifaces_ret[ifaces_count - 1] = g_new0(virDomainInterface, 1);
iface = ifaces_ret[ifaces_count - 1];
iface->naddrs = 0;
if (!shapingPolicy || shapingPolicy->enabled != esxVI_Boolean_True)
return 0;
- if (VIR_ALLOC(*bandwidth) < 0 ||
- VIR_ALLOC((*bandwidth)->in) < 0 ||
- VIR_ALLOC((*bandwidth)->out) < 0)
- return -1;
+ *bandwidth = g_new0(virNetDevBandwidth, 1);
+ (*bandwidth)->in = g_new0(virNetDevBandwidthRate, 1);
+ (*bandwidth)->out = g_new0(virNetDevBandwidthRate, 1);
if (shapingPolicy->averageBandwidth) {
/* Scale bits per second to kilobytes per second */
if (esxVI_EnsureSession(priv->primary) < 0)
return NULL;
- if (VIR_ALLOC(def) < 0)
- goto cleanup;
+ def = g_new0(virNetworkDef, 1);
/* Lookup HostVirtualSwitch */
if (esxVI_LookupHostVirtualSwitchByName(priv->primary, network_->name,
if (count > 0) {
def->forward.type = VIR_NETWORK_FORWARD_BRIDGE;
-
- if (VIR_ALLOC_N(def->forward.ifs, count) < 0)
- goto cleanup;
+ def->forward.ifs = g_new0(virNetworkForwardIfDef, count);
/* Find PhysicalNic by key */
if (esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0)
}
if (count > 0) {
- if (VIR_ALLOC_N(def->portGroups, count) < 0)
- goto cleanup;
+ def->portGroups = g_new0(virPortGroupDef, count);
/* Lookup Network list and create name list */
if (esxVI_String_AppendValueToList(&propertyNameList, "name") < 0 ||
def.source.nhost = 1;
- if (VIR_ALLOC_N(def.source.hosts, def.source.nhost) < 0)
- goto cleanup;
+ def.source.hosts = g_new0(virStoragePoolSourceHost, def.source.nhost);
def.source.hosts[0].name = target->address;
if (esxVI_LocalDatastoreInfo_DynamicCast(info)) {
def.type = VIR_STORAGE_POOL_DIR;
} else if ((nasInfo = esxVI_NasDatastoreInfo_DynamicCast(info))) {
- if (VIR_ALLOC_N(def.source.hosts, 1) < 0)
- goto cleanup;
+ def.source.hosts = g_new0(virStoragePoolSourceHost, 1);
def.type = VIR_STORAGE_POOL_NETFS;
def.source.nhost = 1;
def.source.hosts[0].name = nasInfo->nas->remoteHost;
}
if (priv->primary->hasQueryVirtualDiskUuid) {
- if (VIR_ALLOC_N(key, VIR_UUID_STRING_BUFLEN) < 0)
- goto cleanup;
+ key = g_new0(char, VIR_UUID_STRING_BUFLEN);
if (esxVI_QueryVirtualDiskUuid(priv->primary, datastorePath,
priv->primary->datacenter->_reference,
}
if (priv->primary->hasQueryVirtualDiskUuid) {
- if (VIR_ALLOC_N(key, VIR_UUID_STRING_BUFLEN) < 0)
+ key = g_new0(char, VIR_UUID_STRING_BUFLEN);
goto cleanup;
if (esxVI_QueryVirtualDiskUuid(priv->primary, datastorePath,
priv->backlog_size = input_remaining;
priv->backlog_used = 0;
- if (VIR_ALLOC_N(priv->backlog, priv->backlog_size) < 0)
- return 0;
+ priv->backlog = g_new0(char, priv->backlog_size);
} else if (input_remaining > backlog_remaining) {
priv->backlog_size += input_remaining - backlog_remaining;
return -1;
}
- if (VIR_ALLOC(streamPriv) < 0)
- return -1;
+ streamPriv = g_new0(esxStreamPrivate, 1);
streamPriv->mode = mode;
ESX_VI_CHECK_ARG_LIST(parsedUri);
- if (VIR_ALLOC(*parsedUri) < 0)
- return -1;
+ *parsedUri = g_new0(esxUtil_ParsedUri, 1);
for (i = 0; i < uri->paramsCount; i++) {
virURIParamPtr queryParam = &uri->params[i];
{ \
ESX_VI_CHECK_ARG_LIST(ptrptr); \
\
- if (VIR_ALLOC(*ptrptr) < 0) \
- return -1; \
+ *ptrptr = g_new0(esxVI_##_type, 1); \
return 0; \
}
* To handle this properly in order to pass the info string to VIR_DEBUG
* a zero terminated copy of the info string has to be allocated.
*/
- if (VIR_ALLOC_N(buffer, size + 1) < 0)
- return 0;
+ buffer = g_new0(char, size + 1);
memcpy(buffer, info, size);
buffer[size] = '\0';
ctx->username = g_strdup(username);
ctx->password = g_strdup(password);
- if (VIR_ALLOC(ctx->sessionLock) < 0)
- goto cleanup;
+ ctx->sessionLock = g_new0(virMutex, 1);
if (virMutexInit(ctx->sessionLock) < 0) {
goto cleanup;
}
- if (VIR_ALLOC_N(*key, VIR_UUID_STRING_BUFLEN) < 0)
- goto cleanup;
+ *key = g_new0(char, VIR_UUID_STRING_BUFLEN);
if (esxUtil_ReformatUuid(uuid_string, *key) < 0)
goto cleanup;
{ \
ESX_VI_CHECK_ARG_LIST(ptrptr); \
\
- if (VIR_ALLOC(*ptrptr) < 0) \
- return -1; \
+ *ptrptr = g_new0(esxVI_##__type, 1); \
\
(*ptrptr)->_type = esxVI_Type_##__type; \
\