]> Pileus Git - ~andy/fetchmail/blob - xmalloc.c
Header cleanup.
[~andy/fetchmail] / xmalloc.c
1 /*
2  * xmalloc.c -- allocate space or die 
3  *
4  * For license terms, see the file COPYING in this directory.
5  */
6
7 #include <config.h>
8 #include <stdio.h>
9 #include <string.h>
10 #if defined(STDC_HEADERS)
11 #include  <stdlib.h>
12 #endif
13 #include "fetchmail.h"
14
15 #if defined(HAVE_VOIDPOINTER)
16 #define XMALLOCTYPE void
17 #else
18 #define XMALLOCTYPE char
19 #endif
20
21 XMALLOCTYPE *
22 xmalloc (n)
23 int n;
24 {
25   XMALLOCTYPE *p;
26
27   p = (XMALLOCTYPE *) malloc(n);
28   if (p == (XMALLOCTYPE *) 0) {
29     fputs("fetchmail: malloc failed\n",stderr);
30     exit(PS_UNDEFINED);
31   }
32   return(p);
33 }
34
35 char *xstrdup(s)
36 char *s;
37
38   char *p;
39   p = (char *) xmalloc(strlen(s)+1);
40   strcpy(p,s);
41   return p;
42 }
43
44 /* xmalloc.c ends here */