summaryrefslogtreecommitdiff
path: root/gnu/egcs/gcc/cppalloc.c
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>1999-05-26 13:38:57 +0000
committerMarc Espie <espie@cvs.openbsd.org>1999-05-26 13:38:57 +0000
commit0126e157b87f137fc08dc7f46f6c291b9d06ac5d (patch)
treef8555e3e504eb82b4cd3cba5cec20ae4ce8124ff /gnu/egcs/gcc/cppalloc.c
parentff8e9a4356e55ed142306c3a375fa280800abc86 (diff)
egcs projects compiler system
Exact copy of the snapshot, except for the removal of texinfo/ gcc/ch/ libchill/
Diffstat (limited to 'gnu/egcs/gcc/cppalloc.c')
-rw-r--r--gnu/egcs/gcc/cppalloc.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/gnu/egcs/gcc/cppalloc.c b/gnu/egcs/gcc/cppalloc.c
new file mode 100644
index 00000000000..5c96aff7cb8
--- /dev/null
+++ b/gnu/egcs/gcc/cppalloc.c
@@ -0,0 +1,81 @@
+/* Part of CPP library. (memory allocation - xmalloc etc)
+ Copyright (C) 1986, 87, 89, 92, 93, 94, 1995, 1998 Free Software Foundation, Inc.
+ Written by Per Bothner, 1994.
+ Based on CCCP program by Paul Rubin, June 1986
+ Adapted to ANSI C, Richard Stallman, Jan 1987
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding! */
+
+#include "config.h"
+#include "system.h"
+#include "cpplib.h"
+
+static void memory_full PROTO ((void)) ATTRIBUTE_NORETURN;
+
+static void
+memory_full ()
+{
+ cpp_notice ("%s: Memory exhausted.\n", progname);
+ exit (FATAL_EXIT_CODE);
+}
+
+PTR
+xmalloc (size)
+ size_t size;
+{
+ register PTR ptr = (PTR) malloc (size);
+ if (ptr == 0)
+ memory_full ();
+ return ptr;
+}
+
+PTR
+xcalloc (number, size)
+ size_t number, size;
+{
+ register PTR ptr = (PTR) calloc (number, size);
+ if (ptr == 0)
+ memory_full ();
+ return ptr;
+}
+
+PTR
+xrealloc (old, size)
+ PTR old;
+ size_t size;
+{
+ register PTR ptr;
+ if (old)
+ ptr = (PTR) realloc (old, size);
+ else
+ ptr = (PTR) malloc (size);
+ if (ptr == 0)
+ memory_full ();
+ return ptr;
+}
+
+char *
+xstrdup (input)
+ const char *input;
+{
+ unsigned size = strlen (input);
+ char *output = xmalloc (size + 1);
+ strcpy (output, input);
+ return output;
+}