Refactor fmt_human() and fix a bug
It is not necessary to copy memory or anything. Just keep a pointer to the active prefix-array and assign the length of the arrays to a variable. Make the code more readable by using a switch, be more strict when an invalid base is passed to it and fix a small oversight in the bottom of the code where the base 1024 was forgotten to generalized.
This commit is contained in:

committed by
Aaron Marcher

parent
10dbc9543e
commit
ceb13206a4
2
util.h
2
util.h
@ -10,5 +10,5 @@ void die(const char *, ...);
|
||||
|
||||
int esnprintf(char *str, size_t size, const char *fmt, ...);
|
||||
const char *bprintf(const char *fmt, ...);
|
||||
const char *fmt_human(size_t num, int iec);
|
||||
const char *fmt_human(size_t num, int base);
|
||||
int pscanf(const char *path, const char *fmt, ...);
|
||||
|
Reference in New Issue
Block a user