aboutsummaryrefslogtreecommitdiff
path: root/libexec/rtld-elf/xmalloc.c
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2012-04-05 10:38:07 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2012-04-05 10:38:07 +0000
commit0149ef5fcab8cfbaddd3c62f1500ff1fc16befdc (patch)
tree42a7db319ad868c8c93905e20ab18a84d14173e1 /libexec/rtld-elf/xmalloc.c
parentcbedde6b276cb3457283168a0b576117fbfe3065 (diff)
MFC r233307:
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.
Notes
svn path=/stable/9/; revision=233922
Diffstat (limited to 'libexec/rtld-elf/xmalloc.c')
-rw-r--r--libexec/rtld-elf/xmalloc.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/libexec/rtld-elf/xmalloc.c b/libexec/rtld-elf/xmalloc.c
index 0d992257b986..3783685dc826 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 *