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.
13 #if defined(STDC_HEADERS)
16 #include "fetchmail.h"
19 #if defined(HAVE_VOIDPOINTER)
20 #define XMALLOCTYPE void
22 #define XMALLOCTYPE char
30 p = (XMALLOCTYPE *) malloc(n);
31 if (p == (XMALLOCTYPE *) 0)
33 report(stderr, GT_("malloc failed\n"));
40 xrealloc (XMALLOCTYPE *p, size_t n)
44 p = (XMALLOCTYPE *) realloc(p, n);
45 if (p == (XMALLOCTYPE *) 0)
47 report(stderr, GT_("realloc failed\n"));
53 char *xstrdup(const char *s)
56 p = (char *) xmalloc(strlen(s)+1);
61 #if !defined(HAVE_STRDUP)
62 char *strdup(const char *s)
65 p = (char *) malloc(strlen(s)+1);
70 #endif /* !HAVE_STRDUP */
72 char *xstrndup(const char *s, size_t len)
78 p = (char *)xmalloc(l + 1);
84 /* xmalloc.c ends here */