Include stdio.h.
authorRichard Stallman <rms@gnu.org>
Tue, 28 Sep 1993 23:23:11 +0000 (23:23 +0000)
committerRichard Stallman <rms@gnu.org>
Tue, 28 Sep 1993 23:23:11 +0000 (23:23 +0000)
(xmalloc): New function.

From-SVN: r5520

gcc/bi-arity.c
gcc/bi-opname.c

index 26dde7cbc201998cdbe61ade232030b1ff9157ce..69ed788d3ad3de6691b386a8fbdd5dc1f2b64db9 100644 (file)
@@ -18,6 +18,7 @@ along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 
+#include <stdio.h>
 #include "bi-defs.h"
 
 int
@@ -54,3 +55,20 @@ main ()
       }
   return 0;
 }
+
+/* Safely allocate NBYTES bytes of memory. Returns pointer to block of
+   memory. */
+char *
+xmalloc (nbytes)
+     int nbytes;
+{
+  char *tmp = (char *) malloc (nbytes);
+  
+  if (!tmp)
+    {
+      fprintf (stderr, "can't allocate %d bytes (out of virtual memory)\n", nbytes);
+      exit (1);
+    }
+
+  return tmp;
+}
index ac2d84a52353b8eaee1526ecfbe9631e2a6f8819..52ca500548e192af5aa6d0f5699b64770fc206e5 100644 (file)
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
+#include <stdio.h>
 #include "bi-defs.h"
 
 int
@@ -33,3 +34,20 @@ main()
       printf("\"%s%s\",\n", d->basename, v->name);
   return 0;
 }
+
+/* Safely allocate NBYTES bytes of memory. Returns pointer to block of
+   memory. */
+char *
+xmalloc (nbytes)
+     int nbytes;
+{
+  char *tmp = (char *) malloc (nbytes);
+  
+  if (!tmp)
+    {
+      fprintf (stderr, "can't allocate %d bytes (out of virtual memory)\n", nbytes);
+      exit (1);
+    }
+
+  return tmp;
+}