mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -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:
parent
6e29f02e94
commit
758d3403cd
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user