diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-01 19:59:37 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-01 19:59:37 +0200 |
commit | 899ae5337acc2d24edcd64e570adfc5f3c1a8a8a (patch) | |
tree | 9ec3de6ffce8df5f82d1428d595ffe4028905a3d /libbb/xfuncs_printf.c | |
parent | e2afae6303e871a31a061d03359cfcd5dd86c088 (diff) | |
download | busybox-w32-899ae5337acc2d24edcd64e570adfc5f3c1a8a8a.tar.gz busybox-w32-899ae5337acc2d24edcd64e570adfc5f3c1a8a8a.tar.bz2 busybox-w32-899ae5337acc2d24edcd64e570adfc5f3c1a8a8a.zip |
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/xfuncs_printf.c')
-rw-r--r-- | libbb/xfuncs_printf.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 2bc01ad10..7247c915b 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -25,6 +25,11 @@ | |||
25 | * fail, so callers never need to check for errors. If it returned, it | 25 | * fail, so callers never need to check for errors. If it returned, it |
26 | * succeeded. */ | 26 | * succeeded. */ |
27 | 27 | ||
28 | void FAST_FUNC bb_die_memory_exhausted(void) | ||
29 | { | ||
30 | bb_error_msg_and_die(bb_msg_memory_exhausted); | ||
31 | } | ||
32 | |||
28 | #ifndef DMALLOC | 33 | #ifndef DMALLOC |
29 | /* dmalloc provides variants of these that do abort() on failure. | 34 | /* dmalloc provides variants of these that do abort() on failure. |
30 | * Since dmalloc's prototypes overwrite the impls here as they are | 35 | * Since dmalloc's prototypes overwrite the impls here as they are |
@@ -44,7 +49,7 @@ void* FAST_FUNC xmalloc(size_t size) | |||
44 | { | 49 | { |
45 | void *ptr = malloc(size); | 50 | void *ptr = malloc(size); |
46 | if (ptr == NULL && size != 0) | 51 | if (ptr == NULL && size != 0) |
47 | bb_error_msg_and_die(bb_msg_memory_exhausted); | 52 | bb_die_memory_exhausted(); |
48 | return ptr; | 53 | return ptr; |
49 | } | 54 | } |
50 | 55 | ||
@@ -55,7 +60,7 @@ void* FAST_FUNC xrealloc(void *ptr, size_t size) | |||
55 | { | 60 | { |
56 | ptr = realloc(ptr, size); | 61 | ptr = realloc(ptr, size); |
57 | if (ptr == NULL && size != 0) | 62 | if (ptr == NULL && size != 0) |
58 | bb_error_msg_and_die(bb_msg_memory_exhausted); | 63 | bb_die_memory_exhausted(); |
59 | return ptr; | 64 | return ptr; |
60 | } | 65 | } |
61 | #endif /* DMALLOC */ | 66 | #endif /* DMALLOC */ |
@@ -79,7 +84,7 @@ char* FAST_FUNC xstrdup(const char *s) | |||
79 | t = strdup(s); | 84 | t = strdup(s); |
80 | 85 | ||
81 | if (t == NULL) | 86 | if (t == NULL) |
82 | bb_error_msg_and_die(bb_msg_memory_exhausted); | 87 | bb_die_memory_exhausted(); |
83 | 88 | ||
84 | return t; | 89 | return t; |
85 | } | 90 | } |
@@ -327,14 +332,14 @@ char* FAST_FUNC xasprintf(const char *format, ...) | |||
327 | va_end(p); | 332 | va_end(p); |
328 | 333 | ||
329 | if (r < 0) | 334 | if (r < 0) |
330 | bb_error_msg_and_die(bb_msg_memory_exhausted); | 335 | bb_die_memory_exhausted(); |
331 | return string_ptr; | 336 | return string_ptr; |
332 | } | 337 | } |
333 | 338 | ||
334 | void FAST_FUNC xsetenv(const char *key, const char *value) | 339 | void FAST_FUNC xsetenv(const char *key, const char *value) |
335 | { | 340 | { |
336 | if (setenv(key, value, 1)) | 341 | if (setenv(key, value, 1)) |
337 | bb_error_msg_and_die(bb_msg_memory_exhausted); | 342 | bb_die_memory_exhausted(); |
338 | } | 343 | } |
339 | 344 | ||
340 | /* Handles "VAR=VAL" strings, even those which are part of environ | 345 | /* Handles "VAR=VAL" strings, even those which are part of environ |