1 /* Copyright (C) 1986, 1989 Free Software Foundation, Inc.
2
3 This file is part of GNU indent.
4
5 GNU indent is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 1, or (at your option)
8 any later version.
9
10 GNU indent is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNU indent; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
18
19 #include "indent_globs.h"
20
21 /* Like malloc but get error if no storage available. */
22
23 char *
xmalloc(size)24 xmalloc (size)
25 long size;
26 {
27 register char *val = (char *) calloc (1, size);
28 if (!val)
29 {
30 fprintf (stderr,"indent: Virtual memory exhausted.\n");
31 exit (1);
32 }
33 return val;
34 }
35
36 /* Like realloc but get error if no storage available. */
37
38 char *
xrealloc(ptr,size)39 xrealloc (ptr, size)
40 char *ptr;
41 long size;
42 {
43 register char *val = (char *) realloc (ptr, size);
44 if (!val)
45 {
46 fprintf (stderr,"indent: Virtual memory exhausted.\n");
47 exit (1);
48 }
49 return val;
50 }
51
52