Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
tools/virsh-checkpoint.c | 5 +++--
tools/virsh-domain-monitor.c | 11 +++++------
tools/virsh-domain.c | 24 ++++++++++++------------
tools/virsh-host.c | 22 +++++++++++-----------
tools/virsh-interface.c | 8 ++++----
tools/virsh-network.c | 8 ++++----
tools/virsh-nodedev.c | 12 ++++++------
tools/virsh-nwfilter.c | 8 ++++----
tools/virsh-pool.c | 8 ++++----
tools/virsh-secret.c | 6 +++---
tools/virsh-snapshot.c | 8 ++++----
tools/virsh-volume.c | 8 ++++----
tools/vsh.c | 12 ++++++------
13 files changed, 70 insertions(+), 70 deletions(-)
diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c
index cefdfd7800..ac9d5bd348 100644
--- a/tools/virsh-checkpoint.c
+++ b/tools/virsh-checkpoint.c
@@ -583,11 +583,12 @@ virshCheckpointListCollect(vshControl *ctl,
size_t i;
int count = -1;
virDomainCheckpointPtr *chks;
- virshCheckpointListPtr checkpointlist = vshMalloc(ctl,
- sizeof(*checkpointlist));
+ virshCheckpointListPtr checkpointlist = NULL;
virshCheckpointListPtr ret = NULL;
unsigned int flags = orig_flags;
+ checkpointlist = g_new0(struct virshCheckpointList, 1);
+
if (from)
count = virDomainCheckpointListAllChildren(from, &chks, flags);
else
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index c8a7c0f1b7..e0491d48ac 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -1063,8 +1063,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
DOMBLKSTAT_LEGACY_PRINT(3, stats.wr_bytes);
DOMBLKSTAT_LEGACY_PRINT(4, stats.errs);
} else {
- params = vshCalloc(ctl, nparams, sizeof(*params));
-
+ params = g_new0(virTypedParameter, nparams);
if (virDomainBlockStatsFlags(dom, device, params, &nparams, 0) < 0) {
vshError(ctl, _("Failed to get block stats for domain '%s'
device '%s'"), name, device);
goto cleanup;
@@ -1618,7 +1617,7 @@ virshDomainListFree(virshDomainListPtr domlist)
static virshDomainListPtr
virshDomainListCollect(vshControl *ctl, unsigned int flags)
{
- virshDomainListPtr list = vshMalloc(ctl, sizeof(*list));
+ virshDomainListPtr list = g_new0(struct virshDomainList, 1);
size_t i;
int ret;
int *ids = NULL;
@@ -1680,7 +1679,7 @@ virshDomainListCollect(vshControl *ctl, unsigned int flags)
}
if (nids) {
- ids = vshMalloc(ctl, sizeof(int) * nids);
+ ids = g_new0(int, nids);
if ((nids = virConnectListDomains(priv->conn, ids, nids)) < 0) {
vshError(ctl, "%s", _("Failed to list active
domains"));
@@ -1697,7 +1696,7 @@ virshDomainListCollect(vshControl *ctl, unsigned int flags)
}
if (nnames) {
- names = vshMalloc(ctl, sizeof(char *) * nnames);
+ names = g_new0(char *, nnames);
if ((nnames = virConnectListDefinedDomains(priv->conn, names,
nnames)) < 0) {
@@ -1707,7 +1706,7 @@ virshDomainListCollect(vshControl *ctl, unsigned int flags)
}
}
- list->domains = vshMalloc(ctl, sizeof(virDomainPtr) * (nids + nnames));
+ list->domains = g_new0(virDomainPtr, nids + nnames);
list->ndomains = 0;
/* get active domains */
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index b5e7d8f705..8f11393197 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1431,7 +1431,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- params = vshCalloc(ctl, nparams, sizeof(*params));
+ params = g_new0(virTypedParameter, nparams);
if (virDomainGetBlockIoTune(dom, disk, params, &nparams, flags) != 0) {
vshError(ctl, "%s",
@@ -1629,7 +1629,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
}
/* now go get all the blkio parameters */
- params = vshCalloc(ctl, nparams, sizeof(*params));
+ params = g_new0(virTypedParameter, nparams);
if (virDomainGetBlkioParameters(dom, params, &nparams, flags) != 0) {
vshError(ctl, "%s", _("Unable to get blkio
parameters"));
goto cleanup;
@@ -2372,7 +2372,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd)
transientjob) {
/* New API */
if (bandwidth || granularity || buf_size) {
- params = vshCalloc(ctl, 3, sizeof(*params));
+ params = g_new0(virTypedParameter, 3);
if (bandwidth) {
if (!bytes) {
/* bandwidth is ulong MiB/s, but the typed parameter is
@@ -3375,7 +3375,7 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd)
}
/* get all interface parameters */
- params = vshCalloc(ctl, nparams, sizeof(*params));
+ params = g_new0(virTypedParameter, nparams);
if (virDomainGetInterfaceParameters(dom, device, params, &nparams, flags) !=
0) {
vshError(ctl, "%s", _("Unable to get interface
parameters"));
goto cleanup;
@@ -5243,7 +5243,7 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
}
if (nparams) {
- params = vshMalloc(ctl, sizeof(*params) * nparams);
+ params = g_new0(virTypedParameter, nparams);
memset(params, 0, sizeof(*params) * nparams);
if (flags || current) {
@@ -6894,7 +6894,7 @@ virshVcpuinfoInactive(vshControl *ctl,
return false;
cpumaplen = VIR_CPU_MAPLEN(maxcpu);
- cpumaps = vshMalloc(ctl, virBitmapSize(vcpus) * cpumaplen);
+ cpumaps = g_new0(unsigned char, virBitmapSize(vcpus) * cpumaplen);
if (virDomainGetVcpuPinInfo(dom, virBitmapSize(vcpus),
cpumaps, cpumaplen,
@@ -6943,9 +6943,9 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
if (virDomainGetInfo(dom, &info) != 0)
return false;
- cpuinfo = vshMalloc(ctl, sizeof(virVcpuInfo)*info.nrVirtCpu);
+ cpuinfo = g_new0(virVcpuInfo, info.nrVirtCpu);
cpumaplen = VIR_CPU_MAPLEN(maxcpu);
- cpumaps = vshMalloc(ctl, info.nrVirtCpu * cpumaplen);
+ cpumaps = g_new0(unsigned char, info.nrVirtCpu * cpumaplen);
if ((ncpus = virDomainGetVcpus(dom,
cpuinfo, info.nrVirtCpu,
@@ -7075,7 +7075,7 @@ virshVcpuPinQuery(vshControl *ctl,
}
cpumaplen = VIR_CPU_MAPLEN(maxcpu);
- cpumap = vshMalloc(ctl, ncpus * cpumaplen);
+ cpumap = g_new0(unsigned char, ncpus * cpumaplen);
if ((ncpus = virDomainGetVcpuPinInfo(dom, ncpus, cpumap,
cpumaplen, flags)) >= 0) {
table = vshTableNew(_("VCPU"), _("CPU Affinity"), NULL);
@@ -7291,7 +7291,7 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
flags = VIR_DOMAIN_AFFECT_CURRENT;
cpumaplen = VIR_CPU_MAPLEN(maxcpu);
- cpumap = vshMalloc(ctl, cpumaplen);
+ cpumap = g_new0(unsigned char, cpumaplen);
if (virDomainGetEmulatorPinInfo(dom, cpumap,
cpumaplen, flags) >= 0) {
vshPrintExtra(ctl, "%s %s\n", _("emulator:"), _("CPU
Affinity"));
@@ -9281,7 +9281,7 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd)
}
/* now go get all the memory parameters */
- params = vshCalloc(ctl, nparams, sizeof(*params));
+ params = g_new0(virTypedParameter, nparams);
if (virDomainGetMemoryParameters(dom, params, &nparams, flags) != 0) {
vshError(ctl, "%s", _("Unable to get memory
parameters"));
goto cleanup;
@@ -9554,7 +9554,7 @@ cmdNumatune(vshControl * ctl, const vshCmd * cmd)
}
/* now go get all the numa parameters */
- params = vshCalloc(ctl, nparams, sizeof(*params));
+ params = g_new0(virTypedParameter, nparams);
if (virDomainGetNumaParameters(dom, params, &nparams, flags) != 0) {
vshError(ctl, "%s", _("Unable to get numa parameters"));
goto cleanup;
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 722c47958b..d4eb3f977d 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -197,8 +197,8 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- nodes_free = vshCalloc(ctl, nodes_cnt, sizeof(*nodes_free));
- nodes_id = vshCalloc(ctl, nodes_cnt, sizeof(*nodes_id));
+ nodes_free = g_new0(unsigned long long, nodes_cnt);
+ nodes_id = g_new0(unsigned long, nodes_cnt);
for (i = 0; i < nodes_cnt; i++) {
unsigned long id;
@@ -346,7 +346,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
}
}
- pagesize = vshCalloc(ctl, nodes_cnt, sizeof(*pagesize));
+ pagesize = g_new0(unsigned int, nodes_cnt);
for (i = 0; i < nodes_cnt; i++) {
char *val = virXMLPropString(nodes[i], "size");
@@ -379,12 +379,12 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
npages = nodes_cnt;
VIR_FREE(nodes);
} else {
- pagesize = vshMalloc(ctl, sizeof(*pagesize));
+ pagesize = g_new0(unsigned int, 1);
pagesize[0] = kibibytes;
npages = 1;
}
- counts = vshCalloc(ctl, npages, sizeof(*counts));
+ counts = g_new0(unsigned long long, npages);
nodes_cnt = virXPathNodeSet("/capabilities/host/topology/cells/cell",
ctxt, &nodes);
@@ -429,10 +429,10 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd)
}
/* page size is expected in kibibytes */
- pagesize = vshMalloc(ctl, sizeof(*pagesize));
+ pagesize = g_new0(unsigned int, 1);
pagesize[0] = kibibytes;
- counts = vshMalloc(ctl, sizeof(*counts));
+ counts = g_new0(unsigned long long, 1);
if (virNodeGetFreePages(priv->conn, 1, pagesize,
cell, 1, counts, 0) < 0)
@@ -816,7 +816,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
}
memset(cpu_stats, 0, sizeof(cpu_stats));
- params = vshCalloc(ctl, nparams, sizeof(*params));
+ params = g_new0(virNodeCPUStats, nparams);
for (i = 0; i < 2; i++) {
if (virNodeGetCPUStats(priv->conn, cpuNum, params, &nparams, 0) != 0) {
@@ -930,7 +930,7 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd)
}
/* now go get all the memory parameters */
- params = vshCalloc(ctl, nparams, sizeof(*params));
+ params = g_new0(virNodeMemoryStats, nparams);
if (virNodeGetMemoryStats(priv->conn, cellNum, params, &nparams, 0) != 0) {
vshError(ctl, "%s", _("Unable to get memory stats"));
goto cleanup;
@@ -1158,7 +1158,7 @@ vshExtractCPUDefXMLs(vshControl *ctl,
goto error;
}
- cpus = vshCalloc(ctl, n + 1, sizeof(const char *));
+ cpus = g_new0(char *, n + 1);
for (i = 0; i < n; i++) {
/* If the user provided domain capabilities XML, we need to replace
@@ -1567,7 +1567,7 @@ cmdNodeMemoryTune(vshControl *ctl, const vshCmd *cmd)
}
/* Now go get all the memory parameters */
- params = vshCalloc(ctl, nparams, sizeof(*params));
+ params = g_new0(virTypedParameter, nparams);
if (virNodeGetMemoryParameters(priv->conn, params, &nparams, flags) != 0)
{
vshError(ctl, "%s", _("Unable to get memory
parameters"));
goto cleanup;
diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
index 2bca2483dd..8cdbc6e85f 100644
--- a/tools/virsh-interface.c
+++ b/tools/virsh-interface.c
@@ -185,7 +185,7 @@ static virshInterfaceListPtr
virshInterfaceListCollect(vshControl *ctl,
unsigned int flags)
{
- virshInterfaceListPtr list = vshMalloc(ctl, sizeof(*list));
+ virshInterfaceListPtr list = g_new0(struct virshInterfaceList, 1);
size_t i;
int ret;
char **activeNames = NULL;
@@ -226,7 +226,7 @@ virshInterfaceListCollect(vshControl *ctl,
goto cleanup;
}
if (nActiveIfaces) {
- activeNames = vshMalloc(ctl, sizeof(char *) * nActiveIfaces);
+ activeNames = g_new0(char *, nActiveIfaces);
if ((nActiveIfaces = virConnectListInterfaces(priv->conn, activeNames,
nActiveIfaces)) < 0) {
@@ -243,7 +243,7 @@ virshInterfaceListCollect(vshControl *ctl,
goto cleanup;
}
if (nInactiveIfaces) {
- inactiveNames = vshMalloc(ctl, sizeof(char *) * nInactiveIfaces);
+ inactiveNames = g_new0(char *, nInactiveIfaces);
if ((nInactiveIfaces =
virConnectListDefinedInterfaces(priv->conn, inactiveNames,
@@ -261,7 +261,7 @@ virshInterfaceListCollect(vshControl *ctl,
return list;
}
- list->ifaces = vshMalloc(ctl, sizeof(virInterfacePtr) * (nAllIfaces));
+ list->ifaces = g_new0(virInterfacePtr, nAllIfaces);
list->nifaces = 0;
/* get active interfaces */
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 8a683969f9..c5347660de 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -468,7 +468,7 @@ static virshNetworkListPtr
virshNetworkListCollect(vshControl *ctl,
unsigned int flags)
{
- virshNetworkListPtr list = vshMalloc(ctl, sizeof(*list));
+ virshNetworkListPtr list = g_new0(struct virshNetworkList, 1);
size_t i;
int ret;
char **names = NULL;
@@ -539,7 +539,7 @@ virshNetworkListCollect(vshControl *ctl,
if (nAllNets == 0)
return list;
- names = vshMalloc(ctl, sizeof(char *) * nAllNets);
+ names = g_new0(char *, nAllNets);
/* Retrieve a list of active network names */
if (!VSH_MATCH(VIR_CONNECT_LIST_NETWORKS_FILTERS_ACTIVE) ||
@@ -562,7 +562,7 @@ virshNetworkListCollect(vshControl *ctl,
}
}
- list->nets = vshMalloc(ctl, sizeof(virNetworkPtr) * (nAllNets));
+ list->nets = g_new0(virNetworkPtr, nAllNets);
list->nnets = 0;
/* get active networks */
@@ -1685,7 +1685,7 @@ virshNetworkPortListCollect(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags)
{
- virshNetworkPortListPtr list = vshMalloc(ctl, sizeof(*list));
+ virshNetworkPortListPtr list = g_new0(struct virshNetworkPortList, 1);
int ret;
virNetworkPtr network = NULL;
bool success = false;
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index 2edd403a64..483e36bd53 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -216,7 +216,7 @@ virshNodeDeviceListCollect(vshControl *ctl,
int ncapnames,
unsigned int flags)
{
- virshNodeDeviceListPtr list = vshMalloc(ctl, sizeof(*list));
+ virshNodeDeviceListPtr list = g_new0(struct virshNodeDeviceList, 1);
size_t i;
int ret;
virNodeDevicePtr device;
@@ -256,7 +256,7 @@ virshNodeDeviceListCollect(vshControl *ctl,
if (ndevices == 0)
return list;
- names = vshMalloc(ctl, sizeof(char *) * ndevices);
+ names = g_new0(char *, ndevices);
ndevices = virNodeListDevices(priv->conn, NULL, names, ndevices, 0);
if (ndevices < 0) {
@@ -264,7 +264,7 @@ virshNodeDeviceListCollect(vshControl *ctl,
goto cleanup;
}
- list->devices = vshMalloc(ctl, sizeof(virNodeDevicePtr) * (ndevices));
+ list->devices = g_new0(virNodeDevicePtr, ndevices);
list->ndevices = 0;
/* get the node devices */
@@ -295,7 +295,7 @@ virshNodeDeviceListCollect(vshControl *ctl,
goto cleanup;
}
- caps = vshMalloc(ctl, sizeof(char *) * ncaps);
+ caps = g_new0(char *, ncaps);
if ((ncaps = virNodeDeviceListCaps(device, caps, ncaps)) < 0) {
vshError(ctl, "%s", _("Failed to get capability names of the
device"));
@@ -475,8 +475,8 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
}
if (tree) {
- char **parents = vshMalloc(ctl, sizeof(char *) * list->ndevices);
- char **names = vshMalloc(ctl, sizeof(char *) * list->ndevices);
+ char **parents = g_new0(char *, list->ndevices);
+ char **names = g_new0(char *, list->ndevices);
struct virshNodeList arrays = { names, parents };
for (i = 0; i < list->ndevices; i++)
diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c
index 38790b0081..768a96e949 100644
--- a/tools/virsh-nwfilter.c
+++ b/tools/virsh-nwfilter.c
@@ -243,7 +243,7 @@ static virshNWFilterListPtr
virshNWFilterListCollect(vshControl *ctl,
unsigned int flags)
{
- virshNWFilterListPtr list = vshMalloc(ctl, sizeof(*list));
+ virshNWFilterListPtr list = g_new0(struct virshNWFilterList, 1);
size_t i;
int ret;
virNWFilterPtr filter;
@@ -285,7 +285,7 @@ virshNWFilterListCollect(vshControl *ctl,
if (nfilters == 0)
return list;
- names = vshMalloc(ctl, sizeof(char *) * nfilters);
+ names = g_new0(char *, nfilters);
nfilters = virConnectListNWFilters(priv->conn, names, nfilters);
if (nfilters < 0) {
@@ -293,7 +293,7 @@ virshNWFilterListCollect(vshControl *ctl,
goto cleanup;
}
- list->filters = vshMalloc(ctl, sizeof(virNWFilterPtr) * nfilters);
+ list->filters = g_new0(virNWFilterPtr, nfilters);
list->nfilters = 0;
/* get the network filters */
@@ -664,7 +664,7 @@ static virshNWFilterBindingListPtr
virshNWFilterBindingListCollect(vshControl *ctl,
unsigned int flags)
{
- virshNWFilterBindingListPtr list = vshMalloc(ctl, sizeof(*list));
+ virshNWFilterBindingListPtr list = g_new0(struct virshNWFilterBindingList, 1);
int ret;
bool success = false;
virshControlPtr priv = ctl->privData;
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index 0f82cdb308..7835fa6d75 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -859,7 +859,7 @@ static virshStoragePoolListPtr
virshStoragePoolListCollect(vshControl *ctl,
unsigned int flags)
{
- virshStoragePoolListPtr list = vshMalloc(ctl, sizeof(*list));
+ virshStoragePoolListPtr list = g_new0(struct virshStoragePoolList, 1);
size_t i;
int ret;
char **names = NULL;
@@ -936,7 +936,7 @@ virshStoragePoolListCollect(vshControl *ctl,
if (nAllPools == 0)
return list;
- names = vshMalloc(ctl, sizeof(char *) * nAllPools);
+ names = g_new0(char *, nAllPools);
/* Retrieve a list of active storage pool names */
if (!VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE) ||
@@ -959,7 +959,7 @@ virshStoragePoolListCollect(vshControl *ctl,
}
}
- list->pools = vshMalloc(ctl, sizeof(virStoragePoolPtr) * (nAllPools));
+ list->pools = g_new0(virStoragePoolPtr, nAllPools);
list->npools = 0;
/* get active pools */
@@ -1247,7 +1247,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
if (!(list = virshStoragePoolListCollect(ctl, flags)))
goto cleanup;
- poolInfoTexts = vshCalloc(ctl, list->npools, sizeof(*poolInfoTexts));
+ poolInfoTexts = g_new0(struct poolInfoText, list->npools);
/* Collect the storage pool information for display */
for (i = 0; i < list->npools; i++) {
diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
index 7f1df30090..16accc8ad2 100644
--- a/tools/virsh-secret.c
+++ b/tools/virsh-secret.c
@@ -425,7 +425,7 @@ static virshSecretListPtr
virshSecretListCollect(vshControl *ctl,
unsigned int flags)
{
- virshSecretListPtr list = vshMalloc(ctl, sizeof(*list));
+ virshSecretListPtr list = g_new0(struct virshSecretList, 1);
size_t i;
int ret;
virSecretPtr secret;
@@ -470,7 +470,7 @@ virshSecretListCollect(vshControl *ctl,
if (nsecrets == 0)
return list;
- uuids = vshMalloc(ctl, sizeof(char *) * nsecrets);
+ uuids = g_new0(char *, nsecrets);
nsecrets = virConnectListSecrets(priv->conn, uuids, nsecrets);
if (nsecrets < 0) {
@@ -478,7 +478,7 @@ virshSecretListCollect(vshControl *ctl,
goto cleanup;
}
- list->secrets = vshMalloc(ctl, sizeof(virSecretPtr) * (nsecrets));
+ list->secrets = g_new0(virSecretPtr, nsecrets);
list->nsecrets = 0;
/* get the secrets */
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index b4498df298..478657b5b6 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -1069,7 +1069,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
bool descendants = false;
bool roots = false;
virDomainSnapshotPtr *snaps;
- virshSnapshotListPtr snaplist = vshMalloc(ctl, sizeof(*snaplist));
+ virshSnapshotListPtr snaplist = g_new0(struct virshSnapshotList, 1);
virshSnapshotListPtr ret = NULL;
const char *fromname = NULL;
int start_index = -1;
@@ -1221,7 +1221,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
if (!count)
goto success;
- names = vshCalloc(ctl, sizeof(*names), count);
+ names = g_new0(char *, count);
/* Now that we have a count, collect the list. */
if (from && !priv->useSnapshotOld) {
@@ -1242,7 +1242,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
if (count < 0)
goto cleanup;
- snaplist->snaps = vshCalloc(ctl, sizeof(*snaplist->snaps), count);
+ snaplist->snaps = g_new0(struct virshSnap, count);
snaplist->nsnaps = count;
for (i = 0; i < count; i++) {
snaplist->snaps[i].snap = virDomainSnapshotLookupByName(dom,
@@ -1310,7 +1310,7 @@ virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
}
}
if (!changed) {
- ret = vshMalloc(ctl, sizeof(*snaplist));
+ ret = g_new0(struct virshSnapshotList, 1);
goto cleanup;
}
while (changed && remaining) {
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index cfdda619a7..c86abb863f 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -1283,7 +1283,7 @@ virshStorageVolListCollect(vshControl *ctl,
virStoragePoolPtr pool,
unsigned int flags)
{
- virshStorageVolListPtr list = vshMalloc(ctl, sizeof(*list));
+ virshStorageVolListPtr list = g_new0(struct virshStorageVolList, 1);
size_t i;
char **names = NULL;
virStorageVolPtr vol = NULL;
@@ -1322,13 +1322,13 @@ virshStorageVolListCollect(vshControl *ctl,
return list;
/* Retrieve the list of volume names in the pool */
- names = vshCalloc(ctl, nvols, sizeof(*names));
+ names = g_new0(char *, nvols);
if ((nvols = virStoragePoolListVolumes(pool, names, nvols)) < 0) {
vshError(ctl, "%s", _("Failed to list storage volumes"));
goto cleanup;
}
- list->vols = vshMalloc(ctl, sizeof(virStorageVolPtr) * (nvols));
+ list->vols = g_new0(virStorageVolPtr, nvols);
list->nvols = 0;
/* get the vols */
@@ -1415,7 +1415,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
goto cleanup;
if (list->nvols > 0)
- volInfoTexts = vshCalloc(ctl, list->nvols, sizeof(*volInfoTexts));
+ volInfoTexts = g_new0(struct volInfoText, list->nvols);
/* Collect the rest of the volume information for display */
for (i = 0; i < list->nvols; i++) {
diff --git a/tools/vsh.c b/tools/vsh.c
index 0eddd5349d..98066d17bf 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -1450,7 +1450,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd
**partial)
goto syntaxError;
if (tk != VSH_TK_ARG) {
if (partial) {
- vshCmdOpt *arg = vshMalloc(ctl, sizeof(vshCmdOpt));
+ vshCmdOpt *arg = g_new0(vshCmdOpt, 1);
arg->def = opt;
arg->data = tkdata;
tkdata = NULL;
@@ -1499,7 +1499,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd
**partial)
}
if (opt) {
/* save option */
- vshCmdOpt *arg = vshMalloc(ctl, sizeof(vshCmdOpt));
+ vshCmdOpt *arg = g_new0(vshCmdOpt, 1);
arg->def = opt;
arg->data = tkdata;
@@ -1523,7 +1523,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd
**partial)
/* command parsed -- allocate new struct for the command */
if (cmd) {
- vshCmd *c = vshMalloc(ctl, sizeof(vshCmd));
+ vshCmd *c = g_new0(vshCmd, 1);
vshCmdOpt *tmpopt = first;
/* if we encountered --help, replace parsed command with
@@ -1535,7 +1535,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd
**partial)
help = vshCmddefSearch("help");
vshCommandOptFree(first);
- first = vshMalloc(ctl, sizeof(vshCmdOpt));
+ first = g_new0(vshCmdOpt, 1);
first->def = help->opts;
first->data = g_strdup(cmd->name);
first->next = NULL;
@@ -1579,7 +1579,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd
**partial)
if (partial) {
vshCmd *tmp;
- tmp = vshMalloc(ctl, sizeof(*tmp));
+ tmp = g_new0(vshCmd, 1);
tmp->opts = first;
tmp->def = cmd;
@@ -2653,7 +2653,7 @@ vshReadlineOptionsGenerator(const char *text,
}
name_len = strlen(name);
- ret[ret_size] = vshMalloc(NULL, name_len + 3);
+ ret[ret_size] = g_new0(char, name_len + 3);
g_snprintf(ret[ret_size], name_len + 3, "--%s", name);
ret_size++;
/* Terminate the string list properly. */
--
2.26.2