better rounding function for sigar_mem_calc_ram

This commit is contained in:
Doug MacEachern 2006-06-09 18:38:58 +00:00
parent 071ca22aba
commit 8e5ff7d47d
1 changed files with 5 additions and 5 deletions

View File

@ -312,12 +312,12 @@ int sigar_proc_count(sigar_t *sigar, sigar_uint64_t *total)
int sigar_mem_calc_ram(sigar_t *sigar, sigar_mem_t *mem) int sigar_mem_calc_ram(sigar_t *sigar, sigar_mem_t *mem)
{ {
sigar_uint64_t lram = (mem->total / (1024 * 1024)); sigar_uint64_t total = (mem->total / (1024 * 1024));
int ram = (int)lram; /* must cast after division */ int size = (int)total; /* must cast after division */
int remainder = ram % 8; int ram;
if (remainder > 0) { for (ram=1; size; size >>= 1) {
ram += (8 - remainder); ram <<= 1;
} }
mem->ram = ram; mem->ram = ram;