From 625402758bbbfc93f3af7661c735780ad2f94cd5 Mon Sep 17 00:00:00 2001 From: kib Date: Thu, 22 Mar 2012 14:20:51 +0000 Subject: 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 --- libexec/rtld-elf/xmalloc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'libexec/rtld-elf/xmalloc.c') 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 * -- cgit v1.1