Use glib alloc API for virDomainFSInfo

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Jonathon Jongsma 2020-01-10 17:32:17 -06:00 committed by Michal Privoznik
parent 9a7d618c79
commit b28bf62b3f
3 changed files with 12 additions and 20 deletions

View File

@ -11925,15 +11925,15 @@ virDomainFSInfoFree(virDomainFSInfoPtr info)
if (!info)
return;
VIR_FREE(info->mountpoint);
VIR_FREE(info->name);
VIR_FREE(info->fstype);
g_free(info->mountpoint);
g_free(info->name);
g_free(info->fstype);
for (i = 0; i < info->ndevAlias; i++)
VIR_FREE(info->devAlias[i]);
VIR_FREE(info->devAlias);
g_free(info->devAlias[i]);
g_free(info->devAlias);
VIR_FREE(info);
g_free(info);
}
/**

View File

@ -21938,17 +21938,14 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent,
virDomainFSInfoPtr ret = NULL;
size_t i;
if (VIR_ALLOC(ret) < 0)
goto error;
ret = g_new0(virDomainFSInfo, 1);
ret->mountpoint = g_strdup(agent->mountpoint);
ret->name = g_strdup(agent->name);
ret->fstype = g_strdup(agent->fstype);
if (agent->disks &&
VIR_ALLOC_N(ret->devAlias, agent->ndisks) < 0)
goto error;
if (agent->disks)
ret->devAlias = g_new0(char *, agent->ndisks);
ret->ndevAlias = agent->ndisks;
for (i = 0; i < ret->ndevAlias; i++) {
@ -21966,10 +21963,6 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent,
}
return ret;
error:
virDomainFSInfoFree(ret);
return NULL;
}
/* Returns: 0 on success
@ -21987,8 +21980,7 @@ virDomainFSInfoFormat(qemuAgentFSInfoPtr *agentinfo,
if (nagentinfo < 0)
return ret;
if (VIR_ALLOC_N(info_ret, nagentinfo) < 0)
goto cleanup;
info_ret = g_new0(virDomainFSInfoPtr, nagentinfo);
for (i = 0; i < nagentinfo; i++) {
if (!(info_ret[i] = qemuAgentFSInfoToPublic(agentinfo[i], vmdef)))
@ -22006,7 +21998,7 @@ virDomainFSInfoFormat(qemuAgentFSInfoPtr *agentinfo,
if (info_ret)
virDomainFSInfoFree(info_ret[i]);
}
VIR_FREE(info_ret);
g_free(info_ret);
return ret;
}

View File

@ -7032,7 +7032,7 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr server G_GNUC_UNUSED,
if (ninfo >= 0)
for (i = 0; i < ninfo; i++)
virDomainFSInfoFree(info[i]);
VIR_FREE(info);
g_free(info);
return rv;
}