mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 01:18:00 +03:00
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: Sukrit Bhatnagar <skrtbhtngr@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
46a1f0bb64
commit
d9caa2bc93
@ -822,12 +822,9 @@ virExec(virCommandPtr cmd)
|
|||||||
int
|
int
|
||||||
virRun(const char *const*argv, int *status)
|
virRun(const char *const*argv, int *status)
|
||||||
{
|
{
|
||||||
int ret;
|
VIR_AUTOPTR(virCommand) cmd = virCommandNewArgs(argv);
|
||||||
virCommandPtr cmd = virCommandNewArgs(argv);
|
|
||||||
|
|
||||||
ret = virCommandRun(cmd, status);
|
return virCommandRun(cmd, status);
|
||||||
virCommandFree(cmd);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* WIN32 */
|
#else /* WIN32 */
|
||||||
@ -2960,7 +2957,7 @@ virCommandRunRegex(virCommandPtr cmd,
|
|||||||
int totgroups = 0, ngroup = 0, maxvars = 0;
|
int totgroups = 0, ngroup = 0, maxvars = 0;
|
||||||
char **groups;
|
char **groups;
|
||||||
VIR_AUTOFREE(char *) outbuf = NULL;
|
VIR_AUTOFREE(char *) outbuf = NULL;
|
||||||
char **lines = NULL;
|
VIR_AUTOPTR(virString) lines = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
/* Compile all regular expressions */
|
/* Compile all regular expressions */
|
||||||
@ -3039,7 +3036,6 @@ virCommandRunRegex(virCommandPtr cmd,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virStringListFree(lines);
|
|
||||||
if (groups) {
|
if (groups) {
|
||||||
for (j = 0; j < totgroups; j++)
|
for (j = 0; j < totgroups; j++)
|
||||||
VIR_FREE(groups[j]);
|
VIR_FREE(groups[j]);
|
||||||
|
Loading…
Reference in New Issue
Block a user