As Pino's comment, we should take advantage of macro CLEANUP_FREE_STRING_LIST.
Signed-off-by: Chen Hanxiao <[email protected]> --- daemon/btrfs.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/daemon/btrfs.c b/daemon/btrfs.c index 39392f7..fd93d43 100644 --- a/daemon/btrfs.c +++ b/daemon/btrfs.c @@ -409,7 +409,7 @@ umount (char *fs_buf, const mountable_t *fs) guestfs_int_btrfssubvolume_list * do_btrfs_subvolume_list (const mountable_t *fs) { - char **lines; + CLEANUP_FREE_STRING_LIST char **lines; size_t i = 0; const size_t MAX_ARGS = 64; const char *argv[MAX_ARGS]; @@ -534,13 +534,11 @@ do_btrfs_subvolume_list (const mountable_t *fs) this->btrfssubvolume_path = line; } - free (lines); pcre_free (re); return ret; error: - free_stringslen (lines, nr_subvolumes); if (ret) free (ret->guestfs_int_btrfssubvolume_list_val); free (ret); if (re) pcre_free (re); @@ -1254,7 +1252,7 @@ do_btrfs_qgroup_show (const char *path) CLEANUP_FREE char *err = NULL; CLEANUP_FREE char *out = NULL; int r; - char **lines; + CLEANUP_FREE_STRING_LIST char **lines; path_buf = sysroot_path (path); if (path_buf == NULL) { @@ -1323,11 +1321,9 @@ do_btrfs_qgroup_show (const char *path) this->btrfsqgroup_id = line; } - free (lines); return ret; error: - free_stringslen (lines, nr_qgroups + 2); if (ret) free (ret->guestfs_int_btrfsqgroup_list_val); free (ret); @@ -1707,7 +1703,7 @@ do_btrfs_balance_status (const char *path) char *out; int r; guestfs_int_btrfsbalance *ret; - char **lines; + CLEANUP_FREE_STRING_LIST char **lines; size_t nlines; const char *errptr; int erroffset; @@ -1833,7 +1829,7 @@ do_btrfs_scrub_status (const char *path) char *out; int r; guestfs_int_btrfsscrub *ret; - char **lines; + CLEANUP_FREE_STRING_LIST char **lines; path_buf = sysroot_path (path); if (path_buf == NULL) { -- 2.1.0 _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
