提交 ab96c35a 编写于 作者: J Ján Tomko

virsh-completer: use VIR_AUTOFREE for xmlNodePtr* variables

Signed-off-by: NJán Tomko <jtomko@redhat.com>
上级 d46dd75e
...@@ -128,7 +128,7 @@ virshDomainInterfaceCompleter(vshControl *ctl, ...@@ -128,7 +128,7 @@ virshDomainInterfaceCompleter(vshControl *ctl,
xmlDocPtr xmldoc = NULL; xmlDocPtr xmldoc = NULL;
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
int ninterfaces; int ninterfaces;
xmlNodePtr *interfaces = NULL; VIR_AUTOFREE(xmlNodePtr *) interfaces = NULL;
size_t i; size_t i;
unsigned int domainXMLFlags = 0; unsigned int domainXMLFlags = 0;
char **ret = NULL; char **ret = NULL;
...@@ -167,7 +167,6 @@ virshDomainInterfaceCompleter(vshControl *ctl, ...@@ -167,7 +167,6 @@ virshDomainInterfaceCompleter(vshControl *ctl,
VIR_STEAL_PTR(ret, tmp); VIR_STEAL_PTR(ret, tmp);
cleanup: cleanup:
VIR_FREE(interfaces);
xmlFreeDoc(xmldoc); xmlFreeDoc(xmldoc);
xmlXPathFreeContext(ctxt); xmlXPathFreeContext(ctxt);
return ret; return ret;
...@@ -182,7 +181,7 @@ virshDomainDiskTargetCompleter(vshControl *ctl, ...@@ -182,7 +181,7 @@ virshDomainDiskTargetCompleter(vshControl *ctl,
virshControlPtr priv = ctl->privData; virshControlPtr priv = ctl->privData;
xmlDocPtr xmldoc = NULL; xmlDocPtr xmldoc = NULL;
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
xmlNodePtr *disks = NULL; VIR_AUTOFREE(xmlNodePtr *) disks = NULL;
int ndisks; int ndisks;
size_t i; size_t i;
VIR_AUTOSTRINGLIST tmp = NULL; VIR_AUTOSTRINGLIST tmp = NULL;
...@@ -211,7 +210,6 @@ virshDomainDiskTargetCompleter(vshControl *ctl, ...@@ -211,7 +210,6 @@ virshDomainDiskTargetCompleter(vshControl *ctl,
VIR_STEAL_PTR(ret, tmp); VIR_STEAL_PTR(ret, tmp);
cleanup: cleanup:
VIR_FREE(disks);
xmlFreeDoc(xmldoc); xmlFreeDoc(xmldoc);
xmlXPathFreeContext(ctxt); xmlXPathFreeContext(ctxt);
return ret; return ret;
...@@ -665,7 +663,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl, ...@@ -665,7 +663,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
virshControlPtr priv = ctl->privData; virshControlPtr priv = ctl->privData;
unsigned int npages = 0; unsigned int npages = 0;
xmlNodePtr *pages = NULL; VIR_AUTOFREE(xmlNodePtr *) pages = NULL;
xmlDocPtr doc = NULL; xmlDocPtr doc = NULL;
double size = 0; double size = 0;
size_t i = 0; size_t i = 0;
...@@ -725,7 +723,6 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl, ...@@ -725,7 +723,6 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
cleanup: cleanup:
xmlXPathFreeContext(ctxt); xmlXPathFreeContext(ctxt);
VIR_FREE(pages);
xmlFreeDoc(doc); xmlFreeDoc(doc);
VIR_FREE(path); VIR_FREE(path);
VIR_FREE(pagesize); VIR_FREE(pagesize);
...@@ -838,7 +835,7 @@ virshDomainInterfaceStateCompleter(vshControl *ctl, ...@@ -838,7 +835,7 @@ virshDomainInterfaceStateCompleter(vshControl *ctl,
virMacAddr macaddr; virMacAddr macaddr;
char macstr[VIR_MAC_STRING_BUFLEN] = ""; char macstr[VIR_MAC_STRING_BUFLEN] = "";
int ninterfaces; int ninterfaces;
xmlNodePtr *interfaces = NULL; VIR_AUTOFREE(xmlNodePtr *) interfaces = NULL;
char *xpath = NULL; char *xpath = NULL;
char *state = NULL; char *state = NULL;
VIR_AUTOSTRINGLIST tmp = NULL; VIR_AUTOSTRINGLIST tmp = NULL;
...@@ -888,7 +885,6 @@ virshDomainInterfaceStateCompleter(vshControl *ctl, ...@@ -888,7 +885,6 @@ virshDomainInterfaceStateCompleter(vshControl *ctl,
cleanup: cleanup:
VIR_FREE(state); VIR_FREE(state);
VIR_FREE(xpath); VIR_FREE(xpath);
VIR_FREE(interfaces);
xmlXPathFreeContext(ctxt); xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml); xmlFreeDoc(xml);
return ret; return ret;
...@@ -935,7 +931,7 @@ virshCellnoCompleter(vshControl *ctl, ...@@ -935,7 +931,7 @@ virshCellnoCompleter(vshControl *ctl,
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
virshControlPtr priv = ctl->privData; virshControlPtr priv = ctl->privData;
unsigned int ncells = 0; unsigned int ncells = 0;
xmlNodePtr *cells = NULL; VIR_AUTOFREE(xmlNodePtr *) cells = NULL;
xmlDocPtr doc = NULL; xmlDocPtr doc = NULL;
size_t i = 0; size_t i = 0;
char *cap_xml = NULL; char *cap_xml = NULL;
...@@ -969,7 +965,6 @@ virshCellnoCompleter(vshControl *ctl, ...@@ -969,7 +965,6 @@ virshCellnoCompleter(vshControl *ctl,
cleanup: cleanup:
xmlXPathFreeContext(ctxt); xmlXPathFreeContext(ctxt);
VIR_FREE(cells);
xmlFreeDoc(doc); xmlFreeDoc(doc);
VIR_FREE(cap_xml); VIR_FREE(cap_xml);
return ret; return ret;
...@@ -988,7 +983,7 @@ virshDomainDeviceAliasCompleter(vshControl *ctl, ...@@ -988,7 +983,7 @@ virshDomainDeviceAliasCompleter(vshControl *ctl,
xmlDocPtr xmldoc = NULL; xmlDocPtr xmldoc = NULL;
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
int naliases; int naliases;
xmlNodePtr *aliases = NULL; VIR_AUTOFREE(xmlNodePtr *) aliases = NULL;
size_t i; size_t i;
unsigned int domainXMLFlags = 0; unsigned int domainXMLFlags = 0;
char **ret = NULL; char **ret = NULL;
...@@ -1019,7 +1014,6 @@ virshDomainDeviceAliasCompleter(vshControl *ctl, ...@@ -1019,7 +1014,6 @@ virshDomainDeviceAliasCompleter(vshControl *ctl,
VIR_STEAL_PTR(ret, tmp); VIR_STEAL_PTR(ret, tmp);
cleanup: cleanup:
VIR_FREE(aliases);
xmlFreeDoc(xmldoc); xmlFreeDoc(xmldoc);
xmlXPathFreeContext(ctxt); xmlXPathFreeContext(ctxt);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册