]> Pileus Git - ~andy/fetchmail/blobdiff - xmalloc.c
Minor cleanup patches.
[~andy/fetchmail] / xmalloc.c
index ed0b88e73fc68464c51ea17e6a46eab3f22cedcf..4cd9d40e6500ee459ec0de0aaa5036bff3b63900 100644 (file)
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -28,7 +28,10 @@ xmalloc (int n)
 
     p = (XMALLOCTYPE *) malloc(n);
     if (p == (XMALLOCTYPE *) 0)
-       error(PS_UNDEFINED, errno, _("malloc failed"));
+    {
+       report(stderr, _("malloc failed\n"));
+       exit(PS_UNDEFINED);
+    }
     return(p);
 }
 
@@ -39,7 +42,10 @@ xrealloc (XMALLOCTYPE *p, int n)
        return xmalloc (n);
     p = (XMALLOCTYPE *) realloc(p, n);
     if (p == (XMALLOCTYPE *) 0)
-       error(PS_UNDEFINED, errno, _("realloc failed"));
+    {
+       report(stderr, _("realloc failed\n"));
+       exit(PS_UNDEFINED);
+    }
     return p;
 }
 
@@ -51,4 +57,14 @@ char *xstrdup(const char *s)
     return p;
 }
 
+#if !defined(HAVE_STRDUP)
+char *strdup(const char *s)
+{
+    char *p;
+    p = (char *) malloc(strlen(s)+1);
+    strcpy(p,s);
+    return p;
+}
+#endif /* !HAVE_STRDUP */
+
 /* xmalloc.c ends here */