]> Pileus Git - ~andy/fetchmail/blob - xmalloc.c
Prototypes everywhere.
[~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 (int n)
23 {
24     XMALLOCTYPE *p;
25
26     p = (XMALLOCTYPE *) malloc(n);
27     if (p == (XMALLOCTYPE *) 0) {
28         fputs("fetchmail: malloc failed\n",stderr);
29         exit(PS_UNDEFINED);
30     }
31     return(p);
32 }
33
34 char *xstrdup(char *s)
35 {
36     char *p;
37     p = (char *) xmalloc(strlen(s)+1);
38     strcpy(p,s);
39     return p;
40 }
41
42 /* xmalloc.c ends here */