2 * xmalloc.c -- allocate space or die
4 * Copyright 1998 by Eric S. Raymond.
5 * For license terms, see the file COPYING in this directory.
10 #include <sys/types.h>
14 #if defined(STDC_HEADERS)
17 #include "fetchmail.h"
25 p = (XMALLOCTYPE *) malloc(n);
26 if (p == (XMALLOCTYPE *) 0)
28 report(stderr, GT_("malloc failed\n"));
35 xrealloc (XMALLOCTYPE *p, size_t n)
39 p = (XMALLOCTYPE *) realloc(p, n);
40 if (p == (XMALLOCTYPE *) 0)
42 report(stderr, GT_("realloc failed\n"));
48 char *xstrdup(const char *s)
51 p = (char *) xmalloc(strlen(s)+1);
56 #if !defined(HAVE_STRDUP)
57 char *strdup(const char *s)
60 p = (char *) malloc(strlen(s)+1);
65 #endif /* !HAVE_STRDUP */
67 char *xstrndup(const char *s, size_t len)
73 p = (char *)xmalloc(l + 1);
79 /* xmalloc.c ends here */