virCapsGuestMachinePtr *machines;
size_t i;
- if (VIR_ALLOC_N(machines, nnames) < 0)
- return NULL;
+ machines = g_new0(virCapsGuestMachinePtr, nnames);
for (i = 0; i < nnames; i++) {
- if (VIR_ALLOC(machines[i]) < 0) {
- virCapabilitiesFreeMachines(machines, nnames);
- return NULL;
- }
+ machines[i] = g_new0(virCapsGuestMachine, 1);
machines[i]->name = g_strdup(names[i]);
}
{
virCapsGuestPtr guest;
- if (VIR_ALLOC(guest) < 0)
- goto error;
+ guest = g_new0(virCapsGuest, 1);
guest->ostype = ostype;
guest->arch.id = arch;
{
virCapsGuestDomainPtr dom;
- if (VIR_ALLOC(dom) < 0)
- goto error;
+ dom = g_new0(virCapsGuestDomain, 1);
dom->type = hvtype;
dom->info.emulator = g_strdup(emulator);
return ret;
}
- if (VIR_ALLOC(ret) < 0)
- return ret;
+ ret = g_new0(virCapsDomainData, 1);
ret->ostype = foundguest->ostype;
ret->arch = foundguest->arch.id;
{
virCapsStoragePoolPtr pool;
- if (VIR_ALLOC(pool) < 0)
- goto error;
+ pool = g_new0(virCapsStoragePool, 1);
pool->type = poolType;
return 0;
}
- if (VIR_ALLOC_N(tmp, ndistances) < 0)
- goto cleanup;
+ tmp = g_new0(virCapsHostNUMACellSiblingInfo, ndistances);
for (i = 0; i < ndistances; i++) {
if (!distances[i])
if (virNumaGetPages(node, &pages_size, &pages_avail, NULL, &npages) < 0)
goto cleanup;
- if (VIR_ALLOC_N(*pageinfo, npages) < 0)
- goto cleanup;
+ *pageinfo = g_new0(virCapsHostNUMACellPageInfo, npages);
*npageinfo = npages;
for (i = 0; i < npages; i++) {
int nodecpus = nodeinfo.sockets * nodeinfo.cores * nodeinfo.threads;
cid = 0;
- if (VIR_ALLOC_N(cpus, nodecpus) < 0)
- return -1;
+ cpus = g_new0(virCapsHostNUMACellCPU, nodecpus);
for (s = 0; s < nodeinfo.sockets; s++) {
for (c = 0; c < nodeinfo.cores; c++) {
goto cleanup;
}
- if (VIR_ALLOC_N(cpus, ncpus) < 0)
- goto cleanup;
+ cpus = g_new0(virCapsHostNUMACellCPU, ncpus);
cpu = 0;
for (i = 0; i < virBitmapSize(cpumap); i++) {
for (i = 0; i < caps->host.cache.nbanks; i++) {
virCapsHostCacheBankPtr bank = caps->host.cache.banks[i];
- if (VIR_ALLOC(node) < 0)
- goto cleanup;
+ node = g_new0(virCapsHostMemBWNode, 1);
if (virResctrlInfoGetMemoryBandwidth(caps->host.resctrl,
bank->level, &node->control) > 0) {
if (level < cache_min_level)
continue;
- if (VIR_ALLOC(bank) < 0)
- goto cleanup;
-
+ bank = g_new0(virCapsHostCacheBank, 1);
bank->level = level;
if (virFileReadValueUint(&bank->id,