build: allow overriding host cpu with make variable
[oweals/opkg-lede.git] / libbb / xfuncs.c
index ee90e60a6712ad86f9f109b0436c3446f3c07b74..f577315bb16ff5c46ec93d3f5547bc573e71ec91 100644 (file)
 #include "libbb.h"
 
 
-#ifndef DMALLOC
 extern void *xmalloc(size_t size)
 {
        void *ptr = malloc(size);
        if (ptr == NULL && size != 0)
-               error_msg_and_die(memory_exhausted);
+               perror_msg_and_die("malloc");
        return ptr;
 }
 
@@ -39,7 +38,7 @@ extern void *xrealloc(void *ptr, size_t size)
 {
        ptr = realloc(ptr, size);
        if (ptr == NULL && size != 0)
-               error_msg_and_die(memory_exhausted);
+               perror_msg_and_die("realloc");
        return ptr;
 }
 
@@ -47,7 +46,7 @@ extern void *xcalloc(size_t nmemb, size_t size)
 {
        void *ptr = calloc(nmemb, size);
        if (ptr == NULL && nmemb != 0 && size != 0)
-               error_msg_and_die(memory_exhausted);
+               perror_msg_and_die("calloc");
        return ptr;
 }
 
@@ -60,11 +59,10 @@ extern char * xstrdup (const char *s) {
        t = strdup (s);
 
        if (t == NULL)
-               error_msg_and_die(memory_exhausted);
+               perror_msg_and_die("strdup");
 
        return t;
 }
-#endif
 
 extern char * xstrndup (const char *s, int n) {
        char *t;
@@ -73,7 +71,7 @@ extern char * xstrndup (const char *s, int n) {
                error_msg_and_die("xstrndup bug");
 
        t = xmalloc(++n);
-       
+
        return safe_strncpy(t,s,n);
 }
 
@@ -85,13 +83,6 @@ FILE *xfopen(const char *path, const char *mode)
        return fp;
 }
 
-/* Stupid gcc always includes its own builtin strlen()... */
-#undef strlen
-size_t xstrlen(const char *string)
-{
-       return(strlen(string));
-}
-
 /* END CODE */
 /*
 Local Variables: