]> Pileus Git - ~andy/fetchmail/blob - xalloca.c
Easy bug fixes for this round.
[~andy/fetchmail] / xalloca.c
1 /*
2  * xalloca.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 <errno.h>
10 #include <string.h>
11 #if defined(STDC_HEADERS)
12 #include  <stdlib.h>
13 #endif
14 #if defined(HAVE_ALLOCA_H)
15 #include <alloca.h>
16 #else
17 #ifdef _AIX
18  #pragma alloca
19 #endif
20 #endif
21
22 #include "fetchmail.h"
23
24 #if defined(HAVE_VOIDPOINTER)
25 #define XALLOCATYPE void
26 #else
27 #define XALLOCATYPE char
28 #endif
29
30 XALLOCATYPE *
31 #ifdef __STDC__
32 xalloca (size_t n)
33 #else
34 xalloca (n)
35
36 int n;
37 #endif
38 {
39     XALLOCATYPE *p;
40
41     p = (XALLOCATYPE *) alloca(n);
42     if (p == (XALLOCATYPE *) 0)
43     {
44         report(stderr, GT_("alloca failed\n"));
45         exit(PS_UNDEFINED);
46     }
47     return(p);
48 }
49
50 /* xalloca.c ends here */