diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-09 18:16:40 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-09 18:16:40 +0200 |
commit | 02859aaeb29fb83167364291f1ce26b54c23803b (patch) | |
tree | 93a30e982b81e3bde6af8800bcd0c8f3f0080f52 /libbb/human_readable.c | |
parent | e52da5570eb93d6cb2950e55c48bd22edb5a9f18 (diff) | |
download | busybox-w32-02859aaeb29fb83167364291f1ce26b54c23803b.tar.gz busybox-w32-02859aaeb29fb83167364291f1ce26b54c23803b.tar.bz2 busybox-w32-02859aaeb29fb83167364291f1ce26b54c23803b.zip |
use auto_string() where appropriate to kill a few statics
Custom linker script 'busybox_ldscript' found, using it
function old new delta
static.str 4 - -4
static.passwd 4 0 -4
bb_ask 322 311 -11
ether_print 63 47 -16
UNSPEC_print 82 66 -16
INET_sprint 59 38 -21
INET6_sprint 54 30 -24
make_human_readable_str 292 235 -57
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/7 up/down: 0/-153) Total: -153 bytes
text data bss dec hex filename
939880 992 17480 958352 e9f90 busybox_old
939736 992 17456 958184 e9ee8 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/human_readable.c')
-rw-r--r-- | libbb/human_readable.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/libbb/human_readable.c b/libbb/human_readable.c index 0b2eb777e..5c7fc076f 100644 --- a/libbb/human_readable.c +++ b/libbb/human_readable.c | |||
@@ -37,8 +37,6 @@ const char* FAST_FUNC make_human_readable_str(unsigned long long val, | |||
37 | '\0', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y' | 37 | '\0', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y' |
38 | }; | 38 | }; |
39 | 39 | ||
40 | static char *str; | ||
41 | |||
42 | unsigned frac; /* 0..9 - the fractional digit */ | 40 | unsigned frac; /* 0..9 - the fractional digit */ |
43 | const char *u; | 41 | const char *u; |
44 | const char *fmt; | 42 | const char *fmt; |
@@ -81,12 +79,7 @@ const char* FAST_FUNC make_human_readable_str(unsigned long long val, | |||
81 | #endif | 79 | #endif |
82 | } | 80 | } |
83 | 81 | ||
84 | if (!str) { | 82 | return auto_string(xasprintf(fmt, val, frac, *u)); |
85 | /* sufficient for any width of val */ | ||
86 | str = xmalloc(sizeof(val)*3 + 2 + 3); | ||
87 | } | ||
88 | sprintf(str, fmt, val, frac, *u); | ||
89 | return str; | ||
90 | } | 83 | } |
91 | 84 | ||
92 | 85 | ||