提交 d9caa2bc 编写于 作者: S Sukrit Bhatnagar 提交者: Erik Skultety

util: command: use VIR_AUTOPTR for aggregate types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOPTR macro for declaring aggregate pointer variables,
majority of the calls to *Free functions can be dropped, which
in turn leads to getting rid of most of our cleanup sections.
Signed-off-by: NSukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 46a1f0bb
......@@ -822,12 +822,9 @@ virExec(virCommandPtr cmd)
int
virRun(const char *const*argv, int *status)
{
int ret;
virCommandPtr cmd = virCommandNewArgs(argv);
VIR_AUTOPTR(virCommand) cmd = virCommandNewArgs(argv);
ret = virCommandRun(cmd, status);
virCommandFree(cmd);
return ret;
return virCommandRun(cmd, status);
}
#else /* WIN32 */
......@@ -2960,7 +2957,7 @@ virCommandRunRegex(virCommandPtr cmd,
int totgroups = 0, ngroup = 0, maxvars = 0;
char **groups;
VIR_AUTOFREE(char *) outbuf = NULL;
char **lines = NULL;
VIR_AUTOPTR(virString) lines = NULL;
int ret = -1;
/* Compile all regular expressions */
......@@ -3039,7 +3036,6 @@ virCommandRunRegex(virCommandPtr cmd,
ret = 0;
cleanup:
virStringListFree(lines);
if (groups) {
for (j = 0; j < totgroups; j++)
VIR_FREE(groups[j]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册