diff options
| author | Kaveh R. Ghazi <ghazi@caip.rutgers.edu> | 2001-03-10 04:20:03 +0000 |
|---|---|---|
| committer | Kaveh Ghazi <ghazi@gcc.gnu.org> | 2001-03-10 04:20:03 +0000 |
| commit | f4ce9d906750bad87642454a1cbf8a1b2c2261b0 (patch) | |
| tree | 9c3fac38ed4b4a8e389d091650ec0193e59385b9 /gcc/fixinc/server.c | |
| parent | 0eac29848b3a5bee12b6f8ae6c64c82a9c0f61b1 (diff) | |
| download | gcc-f4ce9d906750bad87642454a1cbf8a1b2c2261b0.zip gcc-f4ce9d906750bad87642454a1cbf8a1b2c2261b0.tar.gz gcc-f4ce9d906750bad87642454a1cbf8a1b2c2261b0.tar.bz2 | |
server.c (load_data, run_shell): Use xmalloc, xrealloc & xcalloc in lieu of malloc, realloc & calloc.
* fixinc/server.c (load_data, run_shell): Use xmalloc, xrealloc &
xcalloc in lieu of malloc, realloc & calloc.
* gencheck.c (xmalloc): Use really_call_malloc, not malloc.
* gengenrtl.c (xmalloc): Likewise.
* gensupport.c (xcalloc, xrealloc, xmalloc): Use the
really_call_* memory allocation routines.
* stmt.c (check_for_full_enumeration_handling): Use
really_call_calloc, not calloc.
* system.h (really_call_malloc, really_call_calloc,
really_call_realloc): Define.
(malloc, realloc, calloc, strdup, bzero, bcmp, rindex): Poison.
f:
* fini.c (main): Use really_call_malloc, not malloc.
From-SVN: r40360
Diffstat (limited to 'gcc/fixinc/server.c')
| -rw-r--r-- | gcc/fixinc/server.c | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/gcc/fixinc/server.c b/gcc/fixinc/server.c index 76785e1..de4d203 100644 --- a/gcc/fixinc/server.c +++ b/gcc/fixinc/server.c @@ -93,10 +93,7 @@ load_data (fp) t_bool got_done = BOOL_FALSE; text_size = sizeof (z_line) * 2; - pz_scan = pz_text = malloc (text_size); - - if (pz_text == (char *) NULL) - return (char *) NULL; + pz_scan = pz_text = xmalloc (text_size); for (;;) { @@ -120,18 +117,9 @@ load_data (fp) if (text_size - used_ct < sizeof (z_line)) { size_t off = (size_t) (pz_scan - pz_text); - void *p; text_size += 4096; - p = realloc ((void *) pz_text, text_size); - if (p == (void *) NULL) - { - fprintf (stderr, "Failed to get 0x%08lX bytes\n", - (long) text_size); - free ((void *) pz_text); - return (char *) NULL; - } - pz_text = (char *) p; + pz_text = xrealloc ((void *) pz_text, text_size); pz_scan = pz_text + off; } } @@ -146,7 +134,7 @@ load_data (fp) while ((pz_scan > pz_text) && ISSPACE (pz_scan[-1])) pz_scan--; *pz_scan = NUL; - return realloc ((void *) pz_text, strlen (pz_text) + 1); + return xrealloc ((void *) pz_text, strlen (pz_text) + 1); } @@ -284,11 +272,8 @@ run_shell (pz_cmd) /* IF it is still not running, THEN return the nil string. */ if (server_id <= 0) { - char *pz = (char *) malloc (1); fprintf (stderr, zNoServer, pz_cmd); - if (pz != (char *) NULL) - *pz = '\0'; - return pz; + return xcalloc (1, 1); } /* Make sure the process will pay attention to us, send the @@ -302,11 +287,8 @@ run_shell (pz_cmd) THEN return an empty string. */ if (server_id == NULLPROCESS) { - char *pz = (char *) malloc (1); fprintf (stderr, zNoServer, pz_cmd); - if (pz != (char *) NULL) - *pz = '\0'; - return pz; + return xcalloc (1, 1); } /* Now try to read back all the data. If we fail due to either a @@ -326,9 +308,7 @@ run_shell (pz_cmd) fprintf (stderr, "CLOSING SHELL SERVER - command failure:\n\t%s\n", pz_cmd); - pz = (char *) malloc (1); - if (pz != (char *) NULL) - *pz = '\0'; + pz = xcalloc (1, 1); } #ifdef DEBUG fprintf( stderr, "run_shell command success: %s\n", pz ); |
