diff options
author | Denys Vlasenko | 2020-12-21 21:36:58 +0100 |
---|---|---|
committer | Denys Vlasenko | 2020-12-21 21:36:58 +0100 |
commit | 00eb23b47aa79461b913b320eba3c95b90e6eec4 (patch) | |
tree | ebeb54dcc6eb977247f5088be9cffc4deaea27e9 /libbb | |
parent | e4202df0918e13130bb511a4ce372cbbe089068d (diff) | |
download | busybox-00eb23b47aa79461b913b320eba3c95b90e6eec4.zip busybox-00eb23b47aa79461b913b320eba3c95b90e6eec4.tar.gz |
bc: do not allocate line editing state until needed
function old new delta
xc_read_line 324 353 +29
free_line_input_t 34 39 +5
xc_vm_init 656 640 -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 34/-16) Total: 18 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/lineedit.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index c3b5738..b3e7aba 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -1417,15 +1417,19 @@ void FAST_FUNC show_history(const line_input_t *st) printf("%4d %s\n", i, st->history[i]); } +# if ENABLE_FEATURE_EDITING_SAVEHISTORY void FAST_FUNC free_line_input_t(line_input_t *n) { -# if ENABLE_FEATURE_EDITING_SAVEHISTORY - int i = n->cnt_history; - while (i > 0) - free(n->history[--i]); -#endif - free(n); + if (n) { + int i = n->cnt_history; + while (i > 0) + free(n->history[--i]); + free(n); + } } +# else +/* #defined to free() in libbb.h */ +# endif # if ENABLE_FEATURE_EDITING_SAVEHISTORY /* We try to ensure that concurrent additions to the history @@ -1506,7 +1510,7 @@ void save_history(line_input_t *st) { FILE *fp; - if (!st->hist_file) + if (!st || !st->hist_file) return; if (st->cnt_history <= st->cnt_history_in_file) return; |