This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch installed for malloc/realloc -> xmalloc/xrealloc
- To: gcc-patches at gcc dot gnu dot org
- Subject: Patch installed for malloc/realloc -> xmalloc/xrealloc
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Thu, 16 Nov 2000 23:18:28 -0500 (EST)
I installed the following obvious patch after bootstrapping on
solaris2.7 with no testsuite regressions.
2000-11-14 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.
f:
* malloc.c (malloc_init): Call xmalloc, not malloc.
diff -rup orig/egcs-CVS20001113/gcc/config/mcore/mcore.c egcs-CVS20001113/gcc/config/mcore/mcore.c
--- orig/egcs-CVS20001113/gcc/config/mcore/mcore.c Sun Nov 12 17:08:59 2000
+++ egcs-CVS20001113/gcc/config/mcore/mcore.c Tue Nov 14 10:59:04 2000
@@ -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 -rup orig/egcs-CVS20001113/gcc/cpplib.c egcs-CVS20001113/gcc/cpplib.c
--- orig/egcs-CVS20001113/gcc/cpplib.c Mon Nov 13 17:34:32 2000
+++ egcs-CVS20001113/gcc/cpplib.c Tue Nov 14 10:46:45 2000
@@ -505,7 +505,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 -rup orig/egcs-CVS20001113/gcc/f/malloc.c egcs-CVS20001113/gcc/f/malloc.c
--- orig/egcs-CVS20001113/gcc/f/malloc.c Sat Mar 27 05:23:59 1999
+++ egcs-CVS20001113/gcc/f/malloc.c Tue Nov 14 10:56:57 2000
@@ -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 -rup orig/egcs-CVS20001113/gcc/fixinc/fixincl.c egcs-CVS20001113/gcc/fixinc/fixincl.c
--- orig/egcs-CVS20001113/gcc/fixinc/fixincl.c Tue Sep 12 10:44:05 2000
+++ egcs-CVS20001113/gcc/fixinc/fixincl.c Tue Nov 14 10:52:54 2000
@@ -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_fil
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 -rup orig/egcs-CVS20001113/gcc/fixinc/fixlib.c egcs-CVS20001113/gcc/fixinc/fixlib.c
--- orig/egcs-CVS20001113/gcc/fixinc/fixlib.c Sat Aug 5 15:23:44 2000
+++ egcs-CVS20001113/gcc/fixinc/fixlib.c Tue Nov 14 10:54:39 2000
@@ -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 -rup orig/egcs-CVS20001113/gcc/mkdeps.c egcs-CVS20001113/gcc/mkdeps.c
--- orig/egcs-CVS20001113/gcc/mkdeps.c Sat Mar 11 08:28:42 2000
+++ egcs-CVS20001113/gcc/mkdeps.c Tue Nov 14 10:49:48 2000
@@ -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++)
{