diff options
Diffstat (limited to 'libbb/xfuncs.c')
-rw-r--r-- | libbb/xfuncs.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index b9d013a24..dde91a2ba 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -20,6 +20,15 @@ | |||
20 | * Since dmalloc's prototypes overwrite the impls here as they are | 20 | * Since dmalloc's prototypes overwrite the impls here as they are |
21 | * included after these prototypes in libbb.h, all is well. | 21 | * included after these prototypes in libbb.h, all is well. |
22 | */ | 22 | */ |
23 | // Warn if we can't allocate size bytes of memory. | ||
24 | void *malloc_or_warn(size_t size) | ||
25 | { | ||
26 | void *ptr = malloc(size); | ||
27 | if (ptr == NULL && size != 0) | ||
28 | bb_error_msg(bb_msg_memory_exhausted); | ||
29 | return ptr; | ||
30 | } | ||
31 | |||
23 | // Die if we can't allocate size bytes of memory. | 32 | // Die if we can't allocate size bytes of memory. |
24 | void *xmalloc(size_t size) | 33 | void *xmalloc(size_t size) |
25 | { | 34 | { |