From: Richard Stallman Date: Tue, 28 Sep 1993 23:23:11 +0000 (+0000) Subject: Include stdio.h. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0ce958d05974a1f56585e9bc6faeaa11f3e09458;p=gcc.git Include stdio.h. (xmalloc): New function. From-SVN: r5520 --- diff --git a/gcc/bi-arity.c b/gcc/bi-arity.c index 26dde7cbc20..69ed788d3ad 100644 --- a/gcc/bi-arity.c +++ b/gcc/bi-arity.c @@ -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 #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; +} diff --git a/gcc/bi-opname.c b/gcc/bi-opname.c index ac2d84a5235..52ca500548e 100644 --- a/gcc/bi-opname.c +++ b/gcc/bi-opname.c @@ -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 #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; +}