source: trunk/third/gcc/cppalloc.c @ 8834

Revision 8834, 1.7 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r8833, which included commits to RCS files with non-trunk default branches.
Line 
1/* Part of CPP library.  (memory allocation - xmalloc etc)
2   Copyright (C) 1986, 87, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
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
7This program is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by the
9Free Software Foundation; either version 2, or (at your option) any
10later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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
25#include "config.h"
26
27static void
28memory_full ()
29{
30  fatal ("Memory exhausted.");
31}
32
33char *
34xmalloc (size)
35     unsigned size;
36{
37  register char *ptr = (char *) malloc (size);
38  if (ptr != 0) return (ptr);
39  memory_full ();
40  /*NOTREACHED*/
41  return 0;
42}
43
44char *
45xrealloc (old, size)
46     char *old;
47     unsigned size;
48{
49  register char *ptr = (char *) realloc (old, size);
50  if (ptr == 0)
51    memory_full ();
52  return ptr;
53}
54
55char *
56xcalloc (number, size)
57     unsigned number, size;
58{
59  register unsigned total = number * size;
60  register char *ptr = (char *) calloc (number, size);
61  if (ptr == 0)
62    memory_full ();
63  return ptr;
64}
Note: See TracBrowser for help on using the repository browser.