From 265ff835ce55d2f468610ea47f4cdb701f1d3c8f Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Tue, 28 Sep 1993 23:23:24 +0000 Subject: [PATCH] (xmalloc): New function. From-SVN: r5521 --- gcc/bi-opcode.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gcc/bi-opcode.c b/gcc/bi-opcode.c index 772b1fed3ad..f453789dd4d 100644 --- a/gcc/bi-opcode.c +++ b/gcc/bi-opcode.c @@ -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; +} -- 2.30.2