From 758d3403cd1221ec89ac3a56183974da6a96dc10 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 16 Oct 2011 16:00:35 -0400 Subject: diskspace: create static function mount_point_list_free This logic is reused in both diskspace and downloadspace check functions, so pull it out into its own static method. Signed-off-by: Dave Reisner Signed-off-by: Dan McGee --- lib/libalpm/diskspace.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index e00bd2d7..cfd6402c 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -55,6 +55,17 @@ static int mount_point_cmp(const void *p1, const void *p2) return -strcmp(mp1->mount_dir, mp2->mount_dir); } +static void mount_point_list_free(alpm_list_t *mount_points) +{ + alpm_list_t *i; + + for(i = mount_points; i; i = i->next) { + alpm_mountpoint_t *data = i->data; + FREE(data->mount_dir); + } + FREELIST(mount_points); +} + static alpm_list_t *mount_point_list(alpm_handle_t *handle) { alpm_list_t *mount_points = NULL, *ptr; @@ -256,7 +267,7 @@ static int check_mountpoint(alpm_handle_t *handle, alpm_mountpoint_t *mp) int _alpm_check_downloadspace(alpm_handle_t *handle, const char *cachedir, size_t num_files, off_t *file_sizes) { - alpm_list_t *i, *mount_points; + alpm_list_t *mount_points; alpm_mountpoint_t *cachedir_mp; size_t j; int error = 0; @@ -289,11 +300,7 @@ int _alpm_check_downloadspace(alpm_handle_t *handle, const char *cachedir, } finish: - for(i = mount_points; i; i = i->next) { - alpm_mountpoint_t *data = i->data; - FREE(data->mount_dir); - } - FREELIST(mount_points); + mount_point_list_free(mount_points); if(error) { RET_ERR(handle, ALPM_ERR_DISK_SPACE, -1); @@ -376,11 +383,7 @@ int _alpm_check_diskspace(alpm_handle_t *handle) } finish: - for(i = mount_points; i; i = i->next) { - alpm_mountpoint_t *data = i->data; - FREE(data->mount_dir); - } - FREELIST(mount_points); + mount_point_list_free(mount_points); if(error) { RET_ERR(handle, ALPM_ERR_DISK_SPACE, -1); -- cgit v1.2.3-70-g09d2