1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-16 06:15:08 -05:00

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 <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dave Reisner 2011-10-16 16:00:35 -04:00 committed by Dan McGee
parent 6e29f02e94
commit 758d3403cd

View File

@ -55,6 +55,17 @@ static int mount_point_cmp(const void *p1, const void *p2)
return -strcmp(mp1->mount_dir, mp2->mount_dir); 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) static alpm_list_t *mount_point_list(alpm_handle_t *handle)
{ {
alpm_list_t *mount_points = NULL, *ptr; 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, int _alpm_check_downloadspace(alpm_handle_t *handle, const char *cachedir,
size_t num_files, off_t *file_sizes) size_t num_files, off_t *file_sizes)
{ {
alpm_list_t *i, *mount_points; alpm_list_t *mount_points;
alpm_mountpoint_t *cachedir_mp; alpm_mountpoint_t *cachedir_mp;
size_t j; size_t j;
int error = 0; int error = 0;
@ -289,11 +300,7 @@ int _alpm_check_downloadspace(alpm_handle_t *handle, const char *cachedir,
} }
finish: finish:
for(i = mount_points; i; i = i->next) { mount_point_list_free(mount_points);
alpm_mountpoint_t *data = i->data;
FREE(data->mount_dir);
}
FREELIST(mount_points);
if(error) { if(error) {
RET_ERR(handle, ALPM_ERR_DISK_SPACE, -1); RET_ERR(handle, ALPM_ERR_DISK_SPACE, -1);
@ -376,11 +383,7 @@ int _alpm_check_diskspace(alpm_handle_t *handle)
} }
finish: finish:
for(i = mount_points; i; i = i->next) { mount_point_list_free(mount_points);
alpm_mountpoint_t *data = i->data;
FREE(data->mount_dir);
}
FREELIST(mount_points);
if(error) { if(error) {
RET_ERR(handle, ALPM_ERR_DISK_SPACE, -1); RET_ERR(handle, ALPM_ERR_DISK_SPACE, -1);