|
version 1.1, 2014/07/30 07:55:27
|
version 1.1.1.2, 2019/10/21 14:58:35
|
|
Line 28
|
Line 28
|
| #include <bmon/utils.h> |
#include <bmon/utils.h> |
| #include <bmon/unit.h> |
#include <bmon/unit.h> |
| |
|
| static struct unit *byte_unit, *bit_unit, *number_unit; | static struct unit *byte_unit, *bit_unit; |
| |
|
| static LIST_HEAD(units); |
static LIST_HEAD(units); |
| |
|
|
Line 124 void fraction_free(struct fraction *f)
|
Line 124 void fraction_free(struct fraction *f)
|
| if (!f) |
if (!f) |
| return; |
return; |
| |
|
| |
list_del(&f->f_list); |
| xfree(f->f_name); |
xfree(f->f_name); |
| xfree(f); |
xfree(f); |
| } |
} |
|
Line 190 char *unit_bytes2str(uint64_t bytes, char *buf, size_t
|
Line 191 char *unit_bytes2str(uint64_t bytes, char *buf, size_t
|
| v = unit_value2str(bytes, byte_unit, &ustr, &prec); |
v = unit_value2str(bytes, byte_unit, &ustr, &prec); |
| snprintf(buf, len, "%'.*f%3s", prec, v, ustr); |
snprintf(buf, len, "%'.*f%3s", prec, v, ustr); |
| } else |
} else |
| snprintf(buf, len, "%llu", (unsigned long long) bytes); | snprintf(buf, len, "%" PRIu64, bytes); |
| |
|
| return buf; |
return buf; |
| } |
} |
|
Line 205 char *unit_bit2str(uint64_t bits, char *buf, size_t le
|
Line 206 char *unit_bit2str(uint64_t bits, char *buf, size_t le
|
| v = unit_value2str(bits, bit_unit, &ustr, &prec); |
v = unit_value2str(bits, bit_unit, &ustr, &prec); |
| snprintf(buf, len, "%'.*f%3s", prec, v, ustr); |
snprintf(buf, len, "%'.*f%3s", prec, v, ustr); |
| } else |
} else |
| snprintf(buf, len, "%llu", (unsigned long long) bits); | snprintf(buf, len, "%" PRIu64, bits); |
| |
|
| return buf; |
return buf; |
| } |
} |