summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-elf/xmalloc.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-03-22 14:20:51 +0000
committerkib <kib@FreeBSD.org>2012-03-22 14:20:51 +0000
commit625402758bbbfc93f3af7661c735780ad2f94cd5 (patch)
tree575831251bf75cadb2609a8e274cbb1bac859020 /libexec/rtld-elf/xmalloc.c
parent348388ff1ced917315af86330df398adb549d318 (diff)
downloadFreeBSD-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.c15
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 *
OpenPOWER on IntegriCloud