From dd3b81b4218512cfedc271dfde65c6011b6aefe9 Mon Sep 17 00:00:00 2001
From: "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu>
Date: Fri, 17 Nov 2000 04:16:55 +0000
Subject: [PATCH] mcore.c (mcore_expand_prolog): Call xmalloc/xrealloc, not
 malloc/realloc.

	* mcore.c (mcore_expand_prolog): Call xmalloc/xrealloc, not
	malloc/realloc.

	* cpplib.c (glue_header_name): Likewise.

	* fixincl.c (run_compiles, start_fixer): Likewise.

	* fixlib.c (load_file_data): Likewise.

	* mkdeps.c (munge): Likewise.

f:
	* malloc.c (malloc_init): Call xmalloc, not malloc.

From-SVN: r37511
---
 gcc/ChangeLog            | 13 +++++++++++++
 gcc/config/mcore/mcore.c |  2 +-
 gcc/cpplib.c             |  2 +-
 gcc/f/ChangeLog          |  4 ++++
 gcc/f/malloc.c           |  3 +--
 gcc/fixinc/fixincl.c     | 20 ++++----------------
 gcc/fixinc/fixlib.c      |  7 ++-----
 gcc/mkdeps.c             |  2 +-
 8 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5bd700c94c2e..79a01946dea6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2000-11-16  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+	* mcore.c (mcore_expand_prolog): Call xmalloc/xrealloc, not
+	malloc/realloc.
+
+	* cpplib.c (glue_header_name): Likewise.
+
+	* fixincl.c (run_compiles, start_fixer): Likewise.
+
+	* fixlib.c (load_file_data): Likewise.
+
+	* mkdeps.c (munge): Likewise.
+
 2000-11-17  Hans-Peter Nilsson  <hp@axis.com>
 
 	* defaults.h [EH_FRAME_SECTION_ASM_OP] (EH_FRAME_SECTION): Remove
diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c
index a94bd3d0023c..c4650232fa57 100644
--- a/gcc/config/mcore/mcore.c
+++ b/gcc/config/mcore/mcore.c
@@ -2324,7 +2324,7 @@ mcore_expand_prolog ()
 	free (mcore_current_function_name);
       
       len = strlen (XSTR (x, 0)) + 1;
-      mcore_current_function_name = (char *) malloc (len);
+      mcore_current_function_name = (char *) xmalloc (len);
       
       memcpy (mcore_current_function_name, XSTR (x, 0), len);
       
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index f85851774486..3094385aabb1 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -528,7 +528,7 @@ glue_header_name (pfile, header)
       if (total_len + len > capacity)
 	{
 	  capacity = (capacity + len) * 2;
-	  buffer = (unsigned char *) realloc (buffer, capacity);
+	  buffer = (unsigned char *) xrealloc (buffer, capacity);
 	}
 
       if (token.flags & PREV_WHITE)
diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog
index ad741b051457..f1cf40948944 100644
--- a/gcc/f/ChangeLog
+++ b/gcc/f/ChangeLog
@@ -1,3 +1,7 @@
+Thu Nov 16 23:14:07 2000  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+	* malloc.c (malloc_init): Call xmalloc, not malloc.
+
 2000-11-10  Rodney Brown  <RodneyBrown@mynd.com>
 
 	* Make-lang.in: Remove OUTPUT_OPTION from g77version.o target.
diff --git a/gcc/f/malloc.c b/gcc/f/malloc.c
index b0d31af81ef0..032c2bfdfbf8 100644
--- a/gcc/f/malloc.c
+++ b/gcc/f/malloc.c
@@ -140,8 +140,7 @@ malloc_init ()
 {
   if (malloc_reserve_ != NULL)
     return;
-  malloc_reserve_ = malloc (20 * 1024);	/* In case of crash, free this first. */
-  assert (malloc_reserve_ != NULL);
+  malloc_reserve_ = xmalloc (20 * 1024); /* In case of crash, free this first. */
 }
 
 /* malloc_pool_display -- Display a pool
diff --git a/gcc/fixinc/fixincl.c b/gcc/fixinc/fixincl.c
index e0513e5bc69c..a1d681720b67 100644
--- a/gcc/fixinc/fixincl.c
+++ b/gcc/fixinc/fixincl.c
@@ -474,14 +474,7 @@ run_compiles ()
 {
   tFixDesc *p_fixd = fixDescList;
   int fix_ct = FIX_COUNT;
-  regex_t *p_re = (regex_t *) malloc (REGEX_COUNT * sizeof (regex_t));
-
-  if (p_re == (regex_t *) NULL)
-    {
-      fprintf (stderr, "fixincl ERROR:  cannot allocate %d bytes for regex\n",
-               REGEX_COUNT * sizeof (regex_t));
-      exit (EXIT_FAILURE);
-    }
+  regex_t *p_re = (regex_t *) xmalloc (REGEX_COUNT * sizeof (regex_t));
 
   /*  Make sure compile_re does not stumble across invalid data */
 
@@ -1036,14 +1029,9 @@ start_fixer (read_fd, p_fixd, pz_fix_file)
   else
     {
       tSCC z_cmd_fmt[] = "file='%s'\n%s";
-      pz_cmd = (char*)malloc (strlen (p_fixd->patch_args[2])
-                               + sizeof( z_cmd_fmt )
-                               + strlen( pz_fix_file ));
-      if (pz_cmd == (char*)NULL)
-        {
-          fputs ("allocation failure\n", stderr);
-          exit (EXIT_FAILURE);
-        }
+      pz_cmd = (char*) xmalloc (strlen (p_fixd->patch_args[2])
+				+ sizeof( z_cmd_fmt )
+				+ strlen( pz_fix_file ));
       sprintf (pz_cmd, z_cmd_fmt, pz_fix_file, p_fixd->patch_args[2]);
       pz_cmd_save = p_fixd->patch_args[2];
       p_fixd->patch_args[2] = pz_cmd;
diff --git a/gcc/fixinc/fixlib.c b/gcc/fixinc/fixlib.c
index 1b134eeb2820..d09474a2faac 100644
--- a/gcc/fixinc/fixlib.c
+++ b/gcc/fixinc/fixlib.c
@@ -46,10 +46,7 @@ load_file_data (fp)
       if (space_left < 1024)
         {
           space_left += 4096;
-         if (pz_data)
-            pz_data = realloc ((void*)pz_data, space_left + space_used + 1 );
-         else
-            pz_data = malloc (space_left + space_used + 1 );
+	  pz_data = xrealloc ((void*)pz_data, space_left + space_used + 1 );
         }
       size_read = fread (pz_data + space_used, 1, space_left, fp);
 
@@ -74,7 +71,7 @@ load_file_data (fp)
       space_used += size_read;
     } while (! feof (fp));
 
-  pz_data = realloc ((void*)pz_data, space_used+1 );
+  pz_data = xrealloc ((void*)pz_data, space_used+1 );
   pz_data[ space_used ] = NUL;
   fclose (fp);
 
diff --git a/gcc/mkdeps.c b/gcc/mkdeps.c
index 08b3b2ef91ba..66417d00fee9 100644
--- a/gcc/mkdeps.c
+++ b/gcc/mkdeps.c
@@ -72,7 +72,7 @@ munge (filename)
     }
 
   /* Now we know how big to make the buffer.  */
-  buffer = malloc (len + 1);
+  buffer = xmalloc (len + 1);
 
   for (p = filename, dst = buffer; *p; p++, dst++)
     {
-- 
GitLab