]>
Commit | Line | Data |
---|---|---|
7f2935c7 | 1 | /* Part of CPP library. (memory allocation - xmalloc etc) |
51723711 | 2 | Copyright (C) 1986, 87, 89, 92 - 95, 1998 Free Software Foundation, Inc. |
7f2935c7 PB |
3 | Written by Per Bothner, 1994. |
4 | Based on CCCP program by by Paul Rubin, June 1986 | |
5 | Adapted to ANSI C, Richard Stallman, Jan 1987 | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify it | |
8 | under the terms of the GNU General Public License as published by the | |
9 | Free Software Foundation; either version 2, or (at your option) any | |
10 | later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
940d9d63 | 19 | Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
7f2935c7 PB |
20 | |
21 | In other words, you are welcome to use, share and improve this program. | |
22 | You are forbidden to forbid anyone else to use, share and improve | |
23 | what you give them. Help stamp out software-hoarding! */ | |
24 | ||
800f087e | 25 | #include "config.h" |
b04cd507 | 26 | #include "system.h" |
426b6fa3 | 27 | #include "cpplib.h" |
800f087e | 28 | |
7f2935c7 PB |
29 | static void |
30 | memory_full () | |
31 | { | |
426b6fa3 PB |
32 | fprintf (stderr, "%s: Memory exhausted.\n", progname); |
33 | exit (FATAL_EXIT_CODE); | |
7f2935c7 PB |
34 | } |
35 | ||
36 | char * | |
37 | xmalloc (size) | |
38 | unsigned size; | |
39 | { | |
40 | register char *ptr = (char *) malloc (size); | |
426b6fa3 PB |
41 | if (ptr == 0) |
42 | memory_full (); | |
43 | return ptr; | |
7f2935c7 PB |
44 | } |
45 | ||
46 | char * | |
47 | xrealloc (old, size) | |
48 | char *old; | |
49 | unsigned size; | |
50 | { | |
51 | register char *ptr = (char *) realloc (old, size); | |
56c66747 PB |
52 | if (ptr == 0) |
53 | memory_full (); | |
54 | return ptr; | |
7f2935c7 | 55 | } |