diff options
author | kib <kib@FreeBSD.org> | 2012-03-22 14:20:51 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2012-03-22 14:20:51 +0000 |
commit | 625402758bbbfc93f3af7661c735780ad2f94cd5 (patch) | |
tree | 575831251bf75cadb2609a8e274cbb1bac859020 /libexec/rtld-elf/xmalloc.c | |
parent | 348388ff1ced917315af86330df398adb549d318 (diff) | |
download | FreeBSD-src-625402758bbbfc93f3af7661c735780ad2f94cd5.zip FreeBSD-src-625402758bbbfc93f3af7661c735780ad2f94cd5.tar.gz |
Use xmalloc() instead of malloc() in the places where malloc() calls
are assumed to not fail.
Make the xcalloc() calling conventions follow the calloc(3) calling
conventions and replace unchecked calls to calloc() with calls to
xcalloc().
Remove redundand declarations from xmalloc.c, which are already
present in rtld.h.
Reviewed by: kan
Discussed with: bde
MFC after: 2 weeks
Diffstat (limited to 'libexec/rtld-elf/xmalloc.c')
-rw-r--r-- | libexec/rtld-elf/xmalloc.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/libexec/rtld-elf/xmalloc.c b/libexec/rtld-elf/xmalloc.c index 0d99225..3783685 100644 --- a/libexec/rtld-elf/xmalloc.c +++ b/libexec/rtld-elf/xmalloc.c @@ -32,14 +32,17 @@ #include "rtld.h" #include "rtld_printf.h" -void *xcalloc(size_t); -void *xmalloc(size_t); -char *xstrdup(const char *); - void * -xcalloc(size_t size) +xcalloc(size_t number, size_t size) { - return memset(xmalloc(size), 0, size); + void *p; + + p = calloc(number, size); + if (p == NULL) { + rtld_fdputstr(STDERR_FILENO, "Out of memory\n"); + _exit(1); + } + return (p); } void * |