diff options
author | Denys Vlasenko | 2018-04-01 19:59:37 +0200 |
---|---|---|
committer | Denys Vlasenko | 2018-04-01 19:59:37 +0200 |
commit | 899ae5337acc2d24edcd64e570adfc5f3c1a8a8a (patch) | |
tree | 9ec3de6ffce8df5f82d1428d595ffe4028905a3d /libbb | |
parent | e2afae6303e871a31a061d03359cfcd5dd86c088 (diff) | |
download | busybox-899ae5337acc2d24edcd64e570adfc5f3c1a8a8a.zip busybox-899ae5337acc2d24edcd64e570adfc5f3c1a8a8a.tar.gz |
libbb: new function bb_die_memory_exhausted
function old new delta
bb_die_memory_exhausted - 10 +10
xstrdup 28 23 -5
xsetenv 27 22 -5
xrealloc 32 27 -5
xputenv 22 17 -5
xmalloc 30 25 -5
xfdopen_helper 40 35 -5
xasprintf 44 39 -5
wget_main 2387 2382 -5
open_socket 54 49 -5
glob_brace 419 414 -5
bb_get_chunk_from_file 146 141 -5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/11 up/down: 10/-55) Total: -45 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/get_line_from_file.c | 2 | ||||
-rw-r--r-- | libbb/wfopen.c | 2 | ||||
-rw-r--r-- | libbb/xfuncs_printf.c | 15 |
3 files changed, 12 insertions, 7 deletions
diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c index d100669..f3d6c62 100644 --- a/libbb/get_line_from_file.c +++ b/libbb/get_line_from_file.c @@ -20,7 +20,7 @@ char* FAST_FUNC bb_get_chunk_from_file(FILE *file, size_t *end) /* grow the line buffer as necessary */ if (!(idx & 0xff)) { if (idx == ((size_t)-1) - 0xff) - bb_error_msg_and_die(bb_msg_memory_exhausted); + bb_die_memory_exhausted(); linebuf = xrealloc(linebuf, idx + 0x100); } linebuf[idx++] = (char) ch; diff --git a/libbb/wfopen.c b/libbb/wfopen.c index 20fe18b..1c7f7f3 100644 --- a/libbb/wfopen.c +++ b/libbb/wfopen.c @@ -42,7 +42,7 @@ static FILE* xfdopen_helper(unsigned fd_and_rw_bit) { FILE* fp = fdopen(fd_and_rw_bit >> 1, fd_and_rw_bit & 1 ? "w" : "r"); if (!fp) - bb_error_msg_and_die(bb_msg_memory_exhausted); + bb_die_memory_exhausted(); return fp; } FILE* FAST_FUNC xfdopen_for_read(int fd) diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 2bc01ad..7247c91 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c @@ -25,6 +25,11 @@ * fail, so callers never need to check for errors. If it returned, it * succeeded. */ +void FAST_FUNC bb_die_memory_exhausted(void) +{ + bb_error_msg_and_die(bb_msg_memory_exhausted); +} + #ifndef DMALLOC /* dmalloc provides variants of these that do abort() on failure. * Since dmalloc's prototypes overwrite the impls here as they are @@ -44,7 +49,7 @@ void* FAST_FUNC xmalloc(size_t size) { void *ptr = malloc(size); if (ptr == NULL && size != 0) - bb_error_msg_and_die(bb_msg_memory_exhausted); + bb_die_memory_exhausted(); return ptr; } @@ -55,7 +60,7 @@ void* FAST_FUNC xrealloc(void *ptr, size_t size) { ptr = realloc(ptr, size); if (ptr == NULL && size != 0) - bb_error_msg_and_die(bb_msg_memory_exhausted); + bb_die_memory_exhausted(); return ptr; } #endif /* DMALLOC */ @@ -79,7 +84,7 @@ char* FAST_FUNC xstrdup(const char *s) t = strdup(s); if (t == NULL) - bb_error_msg_and_die(bb_msg_memory_exhausted); + bb_die_memory_exhausted(); return t; } @@ -327,14 +332,14 @@ char* FAST_FUNC xasprintf(const char *format, ...) va_end(p); if (r < 0) - bb_error_msg_and_die(bb_msg_memory_exhausted); + bb_die_memory_exhausted(); return string_ptr; } void FAST_FUNC xsetenv(const char *key, const char *value) { if (setenv(key, value, 1)) - bb_error_msg_and_die(bb_msg_memory_exhausted); + bb_die_memory_exhausted(); } /* Handles "VAR=VAL" strings, even those which are part of environ |