summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-10-16 22:00:35 +0200
committerDan McGee <dan@archlinux.org>2011-10-17 15:39:09 +0200
commit758d3403cd1221ec89ac3a56183974da6a96dc10 (patch)
tree5deeb9e3008a6636f1f7b373890b21b63bff9f6f /lib/libalpm
parent6e29f02e94022e141eced2e0cdcb5b85894317ad (diff)
downloadpacman-758d3403cd1221ec89ac3a56183974da6a96dc10.tar.gz
pacman-758d3403cd1221ec89ac3a56183974da6a96dc10.tar.xz
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>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/diskspace.c25
1 files changed, 14 insertions, 11 deletions
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);