index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2011-01-09 20:36:42 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-01-10 10:49:55 -0600 |
commit | d03b57f459fb9ab9288991a70c4e7297a7c1d150 (patch) | |
tree | 6bebc7f9ca3c5414a48dc1b5cfa323fd5c00e372 /lib/libalpm/diskspace.c | |
parent | 281a4c0a4f2de217b5d23939fb78b3bbfccc34ca (diff) |
-rw-r--r-- | lib/libalpm/diskspace.c | 20 |
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index 87dca84f..b53d272f 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -38,8 +38,6 @@ #include <sys/types.h> #endif -#include <math.h> - /* libarchive */ #include <archive.h> #include <archive_entry.h> @@ -178,8 +176,9 @@ static int calculate_removed_size(const alpm_list_t *mount_points, } data = mp->data; - data->blocks_needed -= (long)ceil((double)(st.st_size) / - (double)(data->fsp.f_bsize)); + /* the addition of (divisor - 1) performs ceil() with integer division */ + data->blocks_needed -= + (st.st_size + data->fsp.f_bsize - 1) / data->fsp.f_bsize; data->used = 1; } @@ -229,8 +228,9 @@ static int calculate_installed_size(const alpm_list_t *mount_points, } data = mp->data; - data->blocks_needed += (long)ceil((double)(archive_entry_size(entry)) / - (double)(data->fsp.f_bsize)); + /* the addition of (divisor - 1) performs ceil() with integer division */ + data->blocks_needed += + (archive_entry_size(entry) + data->fsp.f_bsize - 1) / data->fsp.f_bsize; data->used = 1; } @@ -259,8 +259,8 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) if(replaces) { numtargs += replaces; for(targ = trans->remove; targ; targ = targ->next, current++) { - double percent = (double)current / (double)numtargs; - PROGRESS(trans, PM_TRANS_PROGRESS_DISKSPACE_START, "", (int)(percent * 100), + int percent = (current * 100) / numtargs; + PROGRESS(trans, PM_TRANS_PROGRESS_DISKSPACE_START, "", percent, numtargs, current); pkg = targ->data; @@ -269,8 +269,8 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) } for(targ = trans->add; targ; targ = targ->next, current++) { - double percent = (double)current / (double)numtargs; - PROGRESS(trans, PM_TRANS_PROGRESS_DISKSPACE_START, "", (int)(percent * 100), + int percent = (current * 100) / numtargs; + PROGRESS(trans, PM_TRANS_PROGRESS_DISKSPACE_START, "", percent, numtargs, current); pkg = targ->data; |