(xmalloc): New function.
authorRichard Stallman <rms@gnu.org>
Tue, 28 Sep 1993 23:23:24 +0000 (23:23 +0000)
committerRichard Stallman <rms@gnu.org>
Tue, 28 Sep 1993 23:23:24 +0000 (23:23 +0000)
From-SVN: r5521

gcc/bi-opcode.c

index 772b1fed3add8ffcbdfc346836800f520fd87778..f453789dd4d6b62644cc253eafe2993b6ee18437 100644 (file)
@@ -51,3 +51,20 @@ enum bytecode_opcode\n{");
 
   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;
+}