aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog82
-rw-r--r--gcc/c-aux-info.c61
-rw-r--r--gcc/cccp.c90
-rw-r--r--gcc/collect2.c32
-rw-r--r--gcc/config/1750a/1750a.h2
-rw-r--r--gcc/config/dsp16xx/dsp16xx.c3
-rw-r--r--gcc/config/i370/i370.h7
-rw-r--r--gcc/config/mips/mips.c3
-rw-r--r--gcc/cppinit.c4
-rw-r--r--gcc/dwarfout.c10
-rw-r--r--gcc/except.c36
-rw-r--r--gcc/gcc.c85
-rw-r--r--gcc/gcov.c36
-rw-r--r--gcc/haifa-sched.c44
-rw-r--r--gcc/mips-tdump.c26
-rw-r--r--gcc/mips-tfile.c123
-rw-r--r--gcc/objc/objc-act.c6
-rw-r--r--gcc/prefix.c26
-rw-r--r--gcc/profile.c4
-rw-r--r--gcc/protoize.c103
-rw-r--r--gcc/reload1.c31
-rw-r--r--gcc/resource.c11
-rw-r--r--gcc/stupid.c34
-rw-r--r--gcc/toplev.c87
24 files changed, 200 insertions, 746 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fb9af08..01e15cc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,85 @@
+Mon Sep 6 22:31:28 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * c-aux-info.c (concat): Don't define.
+
+ * cccp.c (my_strerror): Likewise. All callers changed to use
+ xstrerror instead.
+ (do_include): Call xstrdup, not xmalloc/strcpy.
+ (grow_outbuf): Don't check if xrealloc returns NULL, it can't.
+ (xmalloc, xrealloc, xcalloc, xstrdup): Don't define.
+
+ * collect2.c (my_strsignal): Likewise. All callers changed to use
+ strsignal instead.
+ (locatelib): Call xstrdup, not xmalloc/strcpy.
+
+ * 1750a.h (ASM_OUTPUT_INTERNAL_LABEL): Call xmalloc, not malloc.
+
+ * dsp16xx.c (override_options): Call xstrdup, not xmalloc/strcpy.
+
+ * i370.h (ASM_DECLARE_FUNCTION_NAME): Call xmalloc, not malloc.
+
+ * mips.c (build_mips16_call_stub): Call xstrdup, not xmalloc/strcpy.
+
+ * cppinit.c (cpp_options_init): Call xcalloc, not xmalloc/bzero.
+
+ * dwarfout.c (dwarfout_init): Call concat, not xmalloc/strcpy/...
+
+ * except.c (new_eh_region_entry): Call xmalloc/xrealloc, not
+ malloc/realloc.
+ (find_all_handler_type_matches): Likewise. Don't check return
+ value.
+ (get_new_handler, init_insn_eh_region, process_nestinfo): Call
+ xmalloc, not malloc.
+ (init_eh_nesting_info): Likewise. Call xcalloc, not xmalloc/bzero.
+
+ * gcc.c (xstrerror, xmalloc, xrealloc): Don't define.
+ (init_spec): Call xcalloc, not xmalloc/bzero.
+ (set_spec): Call xstrdup, not save_string.
+ (record_temp_file): Call xstrdup, not xmalloc/strcpy.
+ (find_a_file): Call xstrdup, not xmalloc/strcpy.
+ (process_command): Call xstrdup, not save_string.
+ (main): Call xcalloc, not xmalloc/bzero.
+
+ * gcov.c (xmalloc): Don't define.
+ (create_program_flow_graph): Call xcalloc, not xmalloc/bzero.
+ (scan_for_source_files): Call xstrdup, not xmalloc/strcpy.
+ (output_data): Call xcalloc, not xmalloc/bzero.
+
+ * haifa-sched.c (schedule_insns): Call xcalloc, not xmalloc/bzero.
+
+ * mips-tdump.c (xmalloc): Don't define.
+ (print_symbol): Call xmalloc, not malloc.
+ (read_tfile): Call xcalloc, not calloc.
+
+ * mips-tfile.c (xfree, my_strsignal, xmalloc, xcalloc, xrealloc):
+ Don't define. All callers of xfree/my_strsignal changed to use
+ free/strsignal instead.
+ (allocate_cluster): Call xcalloc, not calloc.
+
+ * objc/objc-act.c (lang_init): Call concat, not xmalloc/strcpy/...
+ Fix memory leak, free allocated memory.
+
+ * prefix.c (translate_name): Call xstrdup, not save_string.
+ (update_path): Likewise.
+
+ * profile.c (branch_prob): Call xstrdup, not xmalloc/strcpy.
+
+ * protoize.c (xstrerror, xmalloc, xrealloc, xfree, savestring2):
+ Don't define. Callers of xfree/savestring2 changed to use
+ free/concat instead.
+
+ * reload1.c (reload): Call xcalloc, not xmalloc/bzero.
+ (init_elim_table): Likewise.
+
+ * resource.c (init_resource_info): Likewise.
+
+ * stupid.c (stupid_life_analysis): Likewise.
+
+ * toplev.c (xmalloc, xcalloc, xrealloc, xstrdup): Don't define.
+ (open_dump_file): Call concat, not xmalloc/strcpy/...
+ (clean_dump_file): Likewise.
+ (compile_file): Call xstrdup, not xmalloc/strcpy.
+
Mon Sep 6 15:04:55 1999 Richard Henderson <rth@cygnus.com>
* v850.h (EXPAND_BUILTIN_VA_ARG): New.
diff --git a/gcc/c-aux-info.c b/gcc/c-aux-info.c
index 9a66350..4131abf 100644
--- a/gcc/c-aux-info.c
+++ b/gcc/c-aux-info.c
@@ -45,67 +45,6 @@ static const char *gen_formal_list_for_func_def PROTO((tree, formals_style));
static const char *gen_type PROTO((const char *, tree, formals_style));
static const char *gen_decl PROTO((tree, int, formals_style));
-/* Concatenate a sequence of strings, returning the result.
-
- This function is based on the one in libiberty. */
-
-/* This definition will conflict with the one from prefix.c in
- libcpp.a when linking cc1 and cc1obj. So only provide it if we are
- not using libcpp.a */
-#ifndef USE_CPPLIB
-char *
-concat VPROTO((const char *first, ...))
-{
- register int length;
- register char *newstr;
- register char *end;
- register const char *arg;
- va_list args;
-#ifndef ANSI_PROTOTYPES
- const char *first;
-#endif
-
- /* First compute the size of the result and get sufficient memory. */
-
- VA_START (args, first);
-#ifndef ANSI_PROTOTYPES
- first = va_arg (args, const char *);
-#endif
-
- arg = first;
- length = 0;
-
- while (arg != 0)
- {
- length += strlen (arg);
- arg = va_arg (args, const char *);
- }
-
- newstr = (char *) malloc (length + 1);
- va_end (args);
-
- /* Now copy the individual pieces to the result string. */
-
- VA_START (args, first);
-#ifndef ANSI_PROTOTYPES
- first = va_arg (args, char *);
-#endif
-
- end = newstr;
- arg = first;
- while (arg != 0)
- {
- while (*arg)
- *end++ = *arg++;
- arg = va_arg (args, const char *);
- }
- *end = '\000';
- va_end (args);
-
- return (newstr);
-}
-#endif /* ! USE_CPPLIB */
-
/* Given a string representing an entire type or an entire declaration
which only lacks the actual "data-type" specifier (at its left end),
affix the data-type specifier to the left end of the given type
diff --git a/gcc/cccp.c b/gcc/cccp.c
index 6be67a9..d4d2a39 100644
--- a/gcc/cccp.c
+++ b/gcc/cccp.c
@@ -964,7 +964,6 @@ static int discard_comments PROTO((U_CHAR *, int, int));
static int change_newlines PROTO((U_CHAR *, int));
-static char *my_strerror PROTO((int));
static void notice PVPROTO((const char *, ...)) ATTRIBUTE_PRINTF_1;
static void vnotice PROTO((const char *, va_list));
void error PVPROTO((const char *, ...)) ATTRIBUTE_PRINTF_1;
@@ -4723,8 +4722,7 @@ get_filename:
/* Actually process the file */
if (pcfbuf) {
- pcfname = xmalloc (strlen (pcftry) + 1);
- strcpy (pcfname, pcftry);
+ pcfname = xstrdup (pcftry);
pcfinclude ((U_CHAR *) pcfbuf, (U_CHAR *) fname, op);
}
else
@@ -9230,38 +9228,6 @@ change_newlines (start, length)
return obp - start;
}
-/* my_strerror - return the descriptive text associated with an
- `errno' code. */
-
-static char *
-my_strerror (errnum)
- int errnum;
-{
- char *result;
-
-#ifndef VMS
-#ifndef HAVE_STRERROR
- result = (char *) ((errnum < sys_nerr) ? sys_errlist[errnum] : 0);
-#else
- result = strerror (errnum);
-#endif
-#else /* VMS */
- /* VAXCRTL's strerror() takes an optional second argument, which only
- matters when the first argument is EVMSERR. However, it's simplest
- just to pass it unconditionally. `vaxc$errno' is declared in
- <errno.h>, and maintained by the library in parallel with `errno'.
- We assume that caller's `errnum' either matches the last setting of
- `errno' by the library or else does not have the value `EVMSERR'. */
-
- result = strerror (errnum, vaxc$errno);
-#endif
-
- if (!result)
- result = "errno = ?";
-
- return result;
-}
-
/* notice - output message to stderr */
static void
@@ -9358,7 +9324,7 @@ error_from_errno (name)
fprintf (stderr, ":%d: ", ip->lineno);
}
- fprintf (stderr, "%s: %s\n", name, my_strerror (e));
+ fprintf (stderr, "%s: %s\n", name, xstrerror (e));
errors++;
}
@@ -9716,8 +9682,7 @@ grow_outbuf (obuf, needed)
if (minsize > obuf->length)
obuf->length = minsize;
- if ((p = (U_CHAR *) xrealloc (obuf->buf, obuf->length)) == NULL)
- memory_full ();
+ p = (U_CHAR *) xrealloc (obuf->buf, obuf->length);
obuf->bufp = p + (obuf->bufp - obuf->buf);
obuf->buf = p;
@@ -10638,7 +10603,7 @@ static void
perror_with_name (name)
char *name;
{
- fprintf (stderr, "%s: %s: %s\n", progname, name, my_strerror (errno));
+ fprintf (stderr, "%s: %s: %s\n", progname, name, xstrerror (errno));
errors++;
}
@@ -10669,53 +10634,6 @@ memory_full ()
{
fatal ("Memory exhausted.");
}
-
-PTR
-xmalloc (size)
- size_t size;
-{
- register PTR ptr = (PTR) malloc (size);
- if (!ptr)
- memory_full ();
- return ptr;
-}
-
-PTR
-xrealloc (old, size)
- PTR old;
- size_t size;
-{
- register PTR ptr;
- if (old)
- ptr = (PTR) realloc (old, size);
- else
- ptr = (PTR) malloc (size);
- if (!ptr)
- memory_full ();
- return ptr;
-}
-
-PTR
-xcalloc (number, size)
- size_t number, size;
-{
- register size_t total = number * size;
- register PTR ptr = (PTR) malloc (total);
- if (!ptr)
- memory_full ();
- bzero (ptr, total);
- return ptr;
-}
-
-char *
-xstrdup (input)
- const char *input;
-{
- register size_t len = strlen (input) + 1;
- register char *output = xmalloc (len);
- memcpy (output, input, len);
- return output;
-}
#ifdef VMS
diff --git a/gcc/collect2.c b/gcc/collect2.c
index c2c38e89..4e61a0d 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -261,7 +261,6 @@ static struct path_prefix *libpaths[3] = {&cmdline_lib_dirs,
static const char *libexts[3] = {"a", "so", NULL}; /* possible library extentions */
#endif
-static const char *my_strsignal PROTO((int));
static void handler PROTO((int));
static int is_ctor_dtor PROTO((const char *));
static char *find_a_file PROTO((struct path_prefix *, const char *));
@@ -321,29 +320,6 @@ dup2 (oldfd, newfd)
return fd;
}
#endif
-
-static const char *
-my_strsignal (s)
- int s;
-{
-#ifdef HAVE_STRSIGNAL
- return strsignal (s);
-#else
- if (s >= 0 && s < NSIG)
- {
-# ifdef NO_SYS_SIGLIST
- static char buffer[30];
-
- sprintf (buffer, "Unknown signal %d", s);
- return buffer;
-# else
- return sys_siglist[s];
-# endif
- }
- else
- return NULL;
-#endif /* HAVE_STRSIGNAL */
-}
/* Delete tempfiles and exit function. */
@@ -1577,7 +1553,7 @@ collect_wait (prog)
: "%s terminated with signal %d [%s], core dumped"),
prog,
sig,
- my_strsignal(sig));
+ strsignal(sig));
collect_exit (FATAL_EXIT_CODE);
}
@@ -2418,8 +2394,7 @@ locatelib (name)
if (*ld_rules == ':')
cnt++;
ld_rules = (char *) (ld_2->ld_rules + code);
- ldr = (char *) xmalloc (strlen (ld_rules) + 1);
- strcpy (ldr, ld_rules);
+ ldr = xstrdup (ld_rules);
}
p = getenv ("LD_LIBRARY_PATH");
q = 0;
@@ -2429,8 +2404,7 @@ locatelib (name)
for (q = p ; *q != 0; q++)
if (*q == ':')
cnt++;
- q = (char *) xmalloc (strlen (p) + 1);
- strcpy (q, p);
+ q = xstrdup (p);
}
l = (const char **) xmalloc ((cnt + 3) * sizeof (char *));
pp = l;
diff --git a/gcc/config/1750a/1750a.h b/gcc/config/1750a/1750a.h
index e341842..9ef5030 100644
--- a/gcc/config/1750a/1750a.h
+++ b/gcc/config/1750a/1750a.h
@@ -1116,7 +1116,7 @@ enum reg_class { NO_REGS, R2, R0_1, INDEX_REGS, BASE_REGS, ALL_REGS, LIM_REG_CLA
do { \
if (strcmp(PREFIX,"LC") == 0) { \
label_pending = 1; \
- datalbl[++datalbl_ndx].name = (char *) malloc (9); \
+ datalbl[++datalbl_ndx].name = (char *) xmalloc (9);\
sprintf(datalbl[datalbl_ndx].name,"LC%d",NUM); \
datalbl[datalbl_ndx].size = 0; \
check_section(Konst); \
diff --git a/gcc/config/dsp16xx/dsp16xx.c b/gcc/config/dsp16xx/dsp16xx.c
index 30e72b4..b1a1a1c 100644
--- a/gcc/config/dsp16xx/dsp16xx.c
+++ b/gcc/config/dsp16xx/dsp16xx.c
@@ -1505,8 +1505,7 @@ override_options ()
if (const_seg_name == (char *) 0)
const_seg_name = DEFAULT_CONST_SEG_NAME;
- save_chip_name = (char *) xmalloc (strlen(chip_name) + 1);
- strcpy (save_chip_name, chip_name);
+ save_chip_name = xstrdup (chip_name);
rsect_text = (char *) xmalloc (strlen(".rsect ") +
strlen(text_seg_name) + 3);
diff --git a/gcc/config/i370/i370.h b/gcc/config/i370/i370.h
index 88656d1..dcacc42 100644
--- a/gcc/config/i370/i370.h
+++ b/gcc/config/i370/i370.h
@@ -1569,12 +1569,7 @@ enum reg_class
if (!mvs_function_name) \
{ \
mvs_function_name_length = strlen (NAME) * 2; \
- mvs_function_name = (char *) malloc (mvs_function_name_length); \
- if (mvs_function_name == 0) \
- { \
- fatal ("virtual memory exceeded"); \
- abort (); \
- } \
+ mvs_function_name = (char *) xmalloc (mvs_function_name_length); \
} \
if (!strcmp (NAME, "main")) \
strcpy (mvs_function_name, "gccmain"); \
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 0b82cd8..a090a2e 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -7973,8 +7973,7 @@ build_mips16_call_stub (retval, fnmem, arg_size, fp_code)
/* Record this stub. */
l = (struct mips16_stub *) xmalloc (sizeof *l);
- l->name = (char *) xmalloc (strlen (fnname) + 1);
- strcpy (l->name, fnname);
+ l->name = xstrdup (fnname);
l->fpret = fpret;
l->next = mips16_stubs;
mips16_stubs = l;
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index c9f7ece..f0088e3 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -525,8 +525,8 @@ cpp_options_init (opts)
opts->cplusplus_comments = 1;
opts->warn_import = 1;
- opts->pending = (struct cpp_pending *) xmalloc (sizeof (struct cpp_pending));
- bzero ((char *) opts->pending, sizeof (struct cpp_pending));
+ opts->pending =
+ (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
}
/* Initialize a cpp_reader structure. */
diff --git a/gcc/dwarfout.c b/gcc/dwarfout.c
index fbc9f44..90c1502 100644
--- a/gcc/dwarfout.c
+++ b/gcc/dwarfout.c
@@ -5814,18 +5814,12 @@ dwarfout_init (asm_out_file, main_input_filename)
ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
ASM_OUTPUT_LABEL (asm_out_file, SFNAMES_BEGIN_LABEL);
{
- register char *pwd;
- register unsigned len;
+ register char *pwd = getpwd ();
register char *dirname;
- pwd = getpwd ();
if (!pwd)
pfatal_with_name ("getpwd");
- len = strlen (pwd);
- dirname = (char *) xmalloc (len + 2);
-
- strcpy (dirname, pwd);
- strcpy (dirname + len, "/");
+ dirname = concat (pwd, "/", NULL);
ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, dirname);
free (dirname);
}
diff --git a/gcc/except.c b/gcc/except.c
index 0a7b9a9..aa9f19a 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -711,14 +711,14 @@ new_eh_region_entry (note_eh_region, rethrow)
if (num_func_eh_entries == 0)
{
function_eh_regions =
- (struct func_eh_entry *) malloc (SIZE_FUNC_EH (50));
+ (struct func_eh_entry *) xmalloc (SIZE_FUNC_EH (50));
num_func_eh_entries = 50;
}
else
{
num_func_eh_entries = num_func_eh_entries * 3 / 2;
function_eh_regions = (struct func_eh_entry *)
- realloc (function_eh_regions, SIZE_FUNC_EH (num_func_eh_entries));
+ xrealloc (function_eh_regions, SIZE_FUNC_EH (num_func_eh_entries));
}
}
function_eh_regions[current_func_eh_entry].range_number = note_eh_region;
@@ -812,10 +812,7 @@ find_all_handler_type_matches (array)
return 0;
max_ptr = 100;
- ptr = (void **)malloc (max_ptr * sizeof (void *));
-
- if (ptr == NULL)
- return 0;
+ ptr = (void **) xmalloc (max_ptr * sizeof (void *));
for (x = 0 ; x < current_func_eh_entry; x++)
{
@@ -839,9 +836,7 @@ find_all_handler_type_matches (array)
if (n_ptr >= max_ptr)
{
max_ptr += max_ptr / 2;
- ptr = (void **)realloc (ptr, max_ptr * sizeof (void *));
- if (ptr == NULL)
- return 0;
+ ptr = (void **) xrealloc (ptr, max_ptr * sizeof (void *));
}
ptr[n_ptr] = val;
n_ptr++;
@@ -861,7 +856,7 @@ get_new_handler (handler, typeinfo)
void *typeinfo;
{
struct handler_info* ptr;
- ptr = (struct handler_info *) malloc (sizeof (struct handler_info));
+ ptr = (struct handler_info *) xmalloc (sizeof (struct handler_info));
ptr->handler_label = handler;
ptr->handler_number = CODE_LABEL_NUMBER (handler);
ptr->type_info = typeinfo;
@@ -2952,7 +2947,7 @@ init_insn_eh_region (first, max_uid)
max_uid = INSN_UID (insn);
maximum_uid = max_uid;
- insn_eh_region = (int *) malloc ((max_uid + 1) * sizeof (int));
+ insn_eh_region = (int *) xmalloc ((max_uid + 1) * sizeof (int));
insn = first;
set_insn_eh_region (&insn, 0);
}
@@ -3033,7 +3028,7 @@ process_nestinfo (block, info, nested_eh_region)
extra = 0;
info->num_handlers[index] = count + extra;
- info->handlers[index] = (handler_info **) malloc ((count + extra)
+ info->handlers[index] = (handler_info **) xmalloc ((count + extra)
* sizeof (handler_info **));
/* First put all our handlers into the list. */
@@ -3081,9 +3076,8 @@ init_eh_nesting_info ()
rtx insn;
int x;
- info = (eh_nesting_info *) malloc (sizeof (eh_nesting_info));
- info->region_index = (int *) malloc ((max_label_num () + 1) * sizeof (int));
- bzero ((char *) info->region_index, (max_label_num () + 1) * sizeof (int));
+ info = (eh_nesting_info *) xmalloc (sizeof (eh_nesting_info));
+ info->region_index = (int *) xcalloc ((max_label_num () + 1), sizeof (int));
nested_eh_region = (int *) alloca ((max_label_num () + 1) * sizeof (int));
bzero ((char *) nested_eh_region, (max_label_num () + 1) * sizeof (int));
@@ -3122,14 +3116,10 @@ init_eh_nesting_info ()
}
region_count++;
- info->handlers = (handler_info ***) malloc (region_count
- * sizeof (handler_info ***));
- info->num_handlers = (int *) malloc (region_count * sizeof (int));
- info->outer_index = (int *) malloc (region_count * sizeof (int));
-
- bzero ((char *) info->handlers, region_count * sizeof (rtx *));
- bzero ((char *) info->num_handlers, region_count * sizeof (int));
- bzero ((char *) info->outer_index, region_count * sizeof (int));
+ info->handlers = (handler_info ***) xcalloc (region_count,
+ sizeof (handler_info ***));
+ info->num_handlers = (int *) xcalloc (region_count, sizeof (int));
+ info->outer_index = (int *) xcalloc (region_count, sizeof (int));
/* Now initialize the handler lists for all exception blocks. */
for (x = 0; x <= max_label_num (); x++)
diff --git a/gcc/gcc.c b/gcc/gcc.c
index c01f2bd..e85b8a9 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1056,26 +1056,6 @@ translate_options (argcp, argvp)
*argcp = newindex;
}
-char *
-xstrerror(e)
- int e;
-{
-#ifdef HAVE_STRERROR
-
- return strerror(e);
-
-#else
-
- if (!e)
- return "errno = 0";
-
- if (e > 0 && e < sys_nerr)
- return sys_errlist[e];
-
- return "errno = ?";
-#endif
-}
-
static char *
skip_whitespace (p)
char *p;
@@ -1181,10 +1161,8 @@ init_spec ()
#ifdef EXTRA_SPECS
extra_specs = (struct spec_list *)
- xmalloc (sizeof(struct spec_list) *
+ xcalloc (sizeof(struct spec_list),
(sizeof(extra_specs_1)/sizeof(extra_specs_1[0])));
- bzero ((PTR) extra_specs, sizeof(struct spec_list) *
- (sizeof(extra_specs_1)/sizeof(extra_specs_1[0])));
for (i = (sizeof(extra_specs_1) / sizeof(extra_specs_1[0])) - 1; i >= 0; i--)
{
@@ -1246,7 +1224,7 @@ set_spec (name, spec)
{
/* Not found - make it */
sl = (struct spec_list *) xmalloc (sizeof (struct spec_list));
- sl->name = save_string (name, strlen (name));
+ sl->name = xstrdup (name);
sl->name_len = name_len;
sl->ptr_spec = &sl->ptr;
sl->alloc_p = 0;
@@ -1258,7 +1236,7 @@ set_spec (name, spec)
old_spec = *(sl->ptr_spec);
*(sl->ptr_spec) = ((spec[0] == '+' && ISSPACE ((unsigned char)spec[1]))
? concat (old_spec, spec + 1, NULL_PTR)
- : save_string (spec, strlen (spec)));
+ : xstrdup (spec));
#ifdef DEBUG_SPECS
if (verbose_flag)
@@ -1740,9 +1718,7 @@ record_temp_file (filename, always_delete, fail_delete)
int always_delete;
int fail_delete;
{
- register char *name;
- name = xmalloc (strlen (filename) + 1);
- strcpy (name, filename);
+ register char * const name = xstrdup (filename);
if (always_delete)
{
@@ -1993,23 +1969,13 @@ find_a_file (pprefix, name, mode)
int len = pprefix->max_len + strlen (name) + strlen (file_suffix) + 1;
#ifdef DEFAULT_ASSEMBLER
- if (! strcmp(name, "as") && access (DEFAULT_ASSEMBLER, mode) == 0) {
- name = DEFAULT_ASSEMBLER;
- len = strlen(name)+1;
- temp = xmalloc (len);
- strcpy (temp, name);
- return temp;
- }
+ if (! strcmp(name, "as") && access (DEFAULT_ASSEMBLER, mode) == 0)
+ return xstrdup (DEFAULT_ASSEMBLER);
#endif
#ifdef DEFAULT_LINKER
- if (! strcmp(name, "ld") && access (DEFAULT_LINKER, mode) == 0) {
- name = DEFAULT_LINKER;
- len = strlen(name)+1;
- temp = xmalloc (len);
- strcpy (temp, name);
- return temp;
- }
+ if (! strcmp(name, "ld") && access (DEFAULT_LINKER, mode) == 0)
+ return xstrdup (DEFAULT_LINKER);
#endif
if (machine_suffix)
@@ -2610,8 +2576,8 @@ process_command (argc, argv)
/* Figure compiler version from version string. */
- compiler_version = temp1 =
- save_string (version_string, strlen (version_string));
+ compiler_version = temp1 = xstrdup (version_string);
+
for (; *temp1; ++temp1)
{
if (*temp1 == ' ')
@@ -5026,13 +4992,11 @@ main (argc, argv)
i = n_infiles;
i += lang_specific_extra_outfiles;
- outfiles = (const char **) xmalloc (i * sizeof (char *));
- bzero ((char *) outfiles, i * sizeof (char *));
+ outfiles = (const char **) xcalloc (i, sizeof (char *));
/* Record which files were specified explicitly as link input. */
- explicit_link_files = xmalloc (n_infiles);
- bzero (explicit_link_files, n_infiles);
+ explicit_link_files = xcalloc (1, n_infiles);
for (i = 0; (int)i < n_infiles; i++)
{
@@ -5257,31 +5221,6 @@ lookup_compiler (name, length, language)
return 0;
}
-PTR
-xmalloc (size)
- size_t size;
-{
- register PTR value = (PTR) malloc (size);
- if (value == 0)
- fatal ("virtual memory exhausted");
- return value;
-}
-
-PTR
-xrealloc (old, size)
- PTR old;
- size_t size;
-{
- register PTR ptr;
- if (old)
- ptr = (PTR) realloc (old, size);
- else
- ptr = (PTR) malloc (size);
- if (ptr == 0)
- fatal ("virtual memory exhausted");
- return ptr;
-}
-
static char *
save_string (s, len)
const char *s;
diff --git a/gcc/gcov.c b/gcc/gcov.c
index cdd8c0d..7aff809 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -267,19 +267,6 @@ fnotice VPROTO ((FILE *file, const char *msgid, ...))
}
-PTR
-xmalloc (size)
- size_t size;
-{
- register PTR value = (PTR) malloc (size);
- if (value == 0)
- {
- fnotice (stderr, "error: virtual memory exhausted");
- exit (FATAL_EXIT_CODE);
- }
- return value;
-}
-
/* More 'friendly' abort that prints the line and file.
config.h can #define abort fancy_abort if you like that sort of thing. */
@@ -508,10 +495,8 @@ create_program_flow_graph (bptr)
/* Read the number of blocks. */
__read_long (&num_blocks, bbg_file, 4);
- /* Create an array of size bb number of bb_info structs. Bzero it. */
- bb_graph = (struct bb_info *) xmalloc (num_blocks
- * sizeof (struct bb_info));
- bzero ((char *) bb_graph, sizeof (struct bb_info) * num_blocks);
+ /* Create an array of size bb number of bb_info structs. */
+ bb_graph = (struct bb_info *) xcalloc (num_blocks, sizeof (struct bb_info));
bptr->bb_graph = bb_graph;
bptr->num_blocks = num_blocks;
@@ -802,8 +787,7 @@ scan_for_source_files ()
/* No sourcefile structure for this file name exists, create
a new one, and append it to the front of the sources list. */
s_ptr = (struct sourcefile *) xmalloc (sizeof(struct sourcefile));
- s_ptr->name = xmalloc (strlen ((char *) ptr) + 1);
- strcpy (s_ptr->name, (char *) ptr);
+ s_ptr->name = xstrdup (ptr);
s_ptr->maxlineno = 0;
s_ptr->next = sources;
sources = s_ptr;
@@ -1019,17 +1003,11 @@ output_data ()
else
source_file_name = s_ptr->name;
- line_counts = (long *) xmalloc (sizeof (long) * s_ptr->maxlineno);
- bzero ((char *) line_counts, sizeof (long) * s_ptr->maxlineno);
- line_exists = xmalloc (s_ptr->maxlineno);
- bzero (line_exists, s_ptr->maxlineno);
+ line_counts = (long *) xcalloc (sizeof (long), s_ptr->maxlineno);
+ line_exists = xcalloc (1, s_ptr->maxlineno);
if (output_branch_probs)
- {
- branch_probs = (struct arcdata **) xmalloc (sizeof (struct arcdata *)
- * s_ptr->maxlineno);
- bzero ((char *) branch_probs,
- sizeof (struct arcdata *) * s_ptr->maxlineno);
- }
+ branch_probs = (struct arcdata **)
+ xcalloc (sizeof (struct arcdata *), s_ptr->maxlineno);
/* There will be a zero at the beginning of the bb info, before the
first list of line numbers, so must initialize block_num to 0. */
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index a4bf5c4..5aa69b6 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -7767,14 +7767,9 @@ schedule_insns (dump_file)
max_uid = (get_max_uid () + 1);
- cant_move = (char *) xmalloc (max_uid * sizeof (char));
- bzero ((char *) cant_move, max_uid * sizeof (char));
-
- fed_by_spec_load = (char *) xmalloc (max_uid * sizeof (char));
- bzero ((char *) fed_by_spec_load, max_uid * sizeof (char));
-
- is_load_insn = (char *) xmalloc (max_uid * sizeof (char));
- bzero ((char *) is_load_insn, max_uid * sizeof (char));
+ cant_move = xcalloc (max_uid, sizeof (char));
+ fed_by_spec_load = xcalloc (max_uid, sizeof (char));
+ is_load_insn = xcalloc (max_uid, sizeof (char));
insn_orig_block = (int *) xmalloc (max_uid * sizeof (int));
insn_luid = (int *) xmalloc (max_uid * sizeof (int));
@@ -7903,17 +7898,17 @@ schedule_insns (dump_file)
We use xmalloc instead of alloca, because max_uid can be very large
when there is a lot of function inlining. If we used alloca, we could
exceed stack limits on some hosts for some inputs. */
- insn_priority = (int *) xmalloc (max_uid * sizeof (int));
- insn_reg_weight = (int *) xmalloc (max_uid * sizeof (int));
- insn_tick = (int *) xmalloc (max_uid * sizeof (int));
- insn_costs = (short *) xmalloc (max_uid * sizeof (short));
- insn_units = (short *) xmalloc (max_uid * sizeof (short));
- insn_blockage = (unsigned int *) xmalloc (max_uid * sizeof (unsigned int));
- insn_ref_count = (int *) xmalloc (max_uid * sizeof (int));
+ insn_priority = (int *) xcalloc (max_uid, sizeof (int));
+ insn_reg_weight = (int *) xcalloc (max_uid, sizeof (int));
+ insn_tick = (int *) xcalloc (max_uid, sizeof (int));
+ insn_costs = (short *) xcalloc (max_uid, sizeof (short));
+ insn_units = (short *) xcalloc (max_uid, sizeof (short));
+ insn_blockage = (unsigned int *) xcalloc (max_uid, sizeof (unsigned int));
+ insn_ref_count = (int *) xcalloc (max_uid, sizeof (int));
/* Allocate for forward dependencies. */
- insn_dep_count = (int *) xmalloc (max_uid * sizeof (int));
- insn_depend = (rtx *) xmalloc (max_uid * sizeof (rtx));
+ insn_dep_count = (int *) xcalloc (max_uid, sizeof (int));
+ insn_depend = (rtx *) xcalloc (max_uid, sizeof (rtx));
if (reload_completed == 0)
{
@@ -7941,8 +7936,7 @@ schedule_insns (dump_file)
{
rtx line;
- line_note = (rtx *) xmalloc (max_uid * sizeof (rtx));
- bzero ((char *) line_note, max_uid * sizeof (rtx));
+ line_note = (rtx *) xcalloc (max_uid, sizeof (rtx));
line_note_head = (rtx *) alloca (n_basic_blocks * sizeof (rtx));
bzero ((char *) line_note_head, n_basic_blocks * sizeof (rtx));
@@ -7961,18 +7955,6 @@ schedule_insns (dump_file)
}
}
- bzero ((char *) insn_priority, max_uid * sizeof (int));
- bzero ((char *) insn_reg_weight, max_uid * sizeof (int));
- bzero ((char *) insn_tick, max_uid * sizeof (int));
- bzero ((char *) insn_costs, max_uid * sizeof (short));
- bzero ((char *) insn_units, max_uid * sizeof (short));
- bzero ((char *) insn_blockage, max_uid * sizeof (unsigned int));
- bzero ((char *) insn_ref_count, max_uid * sizeof (int));
-
- /* Initialize for forward dependencies. */
- bzero ((char *) insn_depend, max_uid * sizeof (rtx));
- bzero ((char *) insn_dep_count, max_uid * sizeof (int));
-
/* Find units used in this fuction, for visualization. */
if (sched_verbose)
init_target_units ();
diff --git a/gcc/mips-tdump.c b/gcc/mips-tdump.c
index 9d3143d..d51a2ee 100644
--- a/gcc/mips-tdump.c
+++ b/gcc/mips-tdump.c
@@ -65,19 +65,6 @@ fatal(s)
exit(FATAL_EXIT_CODE);
}
-/* Same as `malloc' but report error if no memory available. */
-/* Do this before size_t is fiddled with so it matches the prototype
- in libiberty.h . */
-PTR
-xmalloc (size)
- size_t size;
-{
- register PTR value = (PTR) malloc (size);
- if (value == 0)
- fatal ("Virtual memory exhausted.");
- return value;
-}
-
/* Due to size_t being defined in sys/types.h and different
in stddef.h, we have to do this by hand..... Note, these
types are correct for MIPS based systems, and may not be
@@ -928,7 +915,7 @@ print_symbol (sym_ptr, number, strbase, aux_base, ifd, fdp)
if (want_scope)
{
if (free_scope == (scope_t *) 0)
- scope_ptr = (scope_t *) malloc (sizeof (scope_t));
+ scope_ptr = (scope_t *) xmalloc (sizeof (scope_t));
else
{
scope_ptr = free_scope;
@@ -982,7 +969,7 @@ print_symbol (sym_ptr, number, strbase, aux_base, ifd, fdp)
if (want_scope)
{
if (free_scope == (scope_t *) 0)
- scope_ptr = (scope_t *) malloc (sizeof (scope_t));
+ scope_ptr = (scope_t *) xmalloc (sizeof (scope_t));
else
{
scope_ptr = free_scope;
@@ -1434,14 +1421,7 @@ read_tfile __proto((void))
"Auxiliary symbols");
if (sym_hdr.iauxMax > 0)
- {
- aux_used = calloc (sym_hdr.iauxMax, 1);
- if (aux_used == (char *) 0)
- {
- perror ("calloc");
- exit (1);
- }
- }
+ aux_used = xcalloc (sym_hdr.iauxMax, 1);
l_strings = (char *) read_seek ((PTR_T) 0,
sym_hdr.issMax,
diff --git a/gcc/mips-tfile.c b/gcc/mips-tfile.c
index 588f4ef..649d11f 100644
--- a/gcc/mips-tfile.c
+++ b/gcc/mips-tfile.c
@@ -636,7 +636,6 @@ extern void pfatal_with_name
__proto((const char *));
extern void fancy_abort __proto((void));
void botch __proto((const char *));
-extern void xfree __proto((PTR));
extern void fatal PVPROTO((const char *format, ...)) ATTRIBUTE_PRINTF_1;
extern void error PVPROTO((const char *format, ...)) ATTRIBUTE_PRINTF_1;
@@ -1693,7 +1692,6 @@ STATIC void free_thead __proto((thead_t *));
STATIC char *local_index __proto((const char *, int));
STATIC char *local_rindex __proto((const char *, int));
-STATIC const char *my_strsignal __proto((int));
extern char *mktemp __proto((char *));
extern long strtol __proto((const char *, char **, int));
@@ -5022,29 +5020,6 @@ main (argc, argv)
}
-STATIC const char *
-my_strsignal (s)
- int s;
-{
-#ifdef HAVE_STRSIGNAL
- return strsignal (s);
-#else
- if (s >= 0 && s < NSIG)
- {
-# ifdef NO_SYS_SIGLIST
- static char buffer[30];
-
- sprintf (buffer, "Unknown signal %d", s);
- return buffer;
-# else
- return sys_siglist[s];
-# endif
- }
- else
- return NULL;
-#endif /* HAVE_STRSIGNAL */
-}
-
/* Catch a signal and exit without dumping core. */
STATIC void
@@ -5052,7 +5027,7 @@ catch_signal (signum)
int signum;
{
(void) signal (signum, SIG_DFL); /* just in case... */
- fatal (my_strsignal(signum));
+ fatal (strsignal(signum));
}
/* Print a fatal error message. NAME is the text.
@@ -5111,10 +5086,7 @@ STATIC page_t *
allocate_cluster (npages)
Size_t npages;
{
- register page_t *value = (page_t *) calloc (npages, PAGE_USIZE);
-
- if (value == 0)
- fatal ("Virtual memory exhausted.");
+ register page_t *value = (page_t *) xcalloc (npages, PAGE_USIZE);
if (debug > 3)
fprintf (stderr, "\talloc\tnpages = %d, value = 0x%.8x\n", npages, value);
@@ -5297,7 +5269,7 @@ free_scope (ptr)
alloc_counts[ (int)alloc_type_scope ].free_list.f_scope = ptr;
#else
- xfree ((PTR_T) ptr);
+ free ((PTR_T) ptr);
#endif
}
@@ -5454,7 +5426,7 @@ free_tag (ptr)
alloc_counts[ (int)alloc_type_tag ].free_list.f_tag = ptr;
#else
- xfree ((PTR_T) ptr);
+ free ((PTR_T) ptr);
#endif
}
@@ -5512,7 +5484,7 @@ free_forward (ptr)
alloc_counts[ (int)alloc_type_forward ].free_list.f_forward = ptr;
#else
- xfree ((PTR_T) ptr);
+ free ((PTR_T) ptr);
#endif
}
@@ -5570,7 +5542,7 @@ free_thead (ptr)
alloc_counts[ (int)alloc_type_thead ].free_list.f_thead = ptr;
#else
- xfree ((PTR_T) ptr);
+ free ((PTR_T) ptr);
#endif
}
@@ -5661,89 +5633,6 @@ botch (s)
fatal (s);
}
-/* Same as `malloc' but report error if no memory available. */
-
-PTR
-xmalloc (size)
- size_t size;
-{
- register PTR value = (PTR) malloc (size);
- if (value == 0)
- fatal ("Virtual memory exhausted.");
-
- if (debug > 3)
- {
- fputs ("\tmalloc\tptr = ", stderr);
- fprintf (stderr, HOST_PTR_PRINTF, value);
- fprintf (stderr, ", size = %10lu\n", (unsigned long) size);
- }
-
- return value;
-}
-
-/* Same as `calloc' but report error if no memory available. */
-
-PTR
-xcalloc (size1, size2)
- size_t size1, size2;
-{
- register PTR value = (PTR) calloc (size1, size2);
- if (value == 0)
- fatal ("Virtual memory exhausted.");
-
- if (debug > 3)
- {
- fputs ("\tcalloc\tptr = ", stderr);
- fprintf (stderr, HOST_PTR_PRINTF, value);
- fprintf (stderr, ", size1 = %10lu, size2 = %10lu [%lu]\n",
- (unsigned long) size1, (unsigned long) size2,
- (unsigned long) size1*size2);
- }
-
- return value;
-}
-
-/* Same as `realloc' but report error if no memory available. */
-
-PTR
-xrealloc (ptr, size)
- PTR ptr;
- size_t size;
-{
- register PTR result;
- if (ptr)
- result = (PTR) realloc (ptr, size);
- else
- result = (PTR) malloc (size);
- if (!result)
- fatal ("Virtual memory exhausted.");
-
- if (debug > 3)
- {
- fputs ("\trealloc\tptr = ", stderr);
- fprintf (stderr, HOST_PTR_PRINTF, result);
- fprintf (stderr, ", size = %10lu, orig = ", size);
- fprintf (stderr, HOST_PTR_PRINTF, ptr);
- fputs ("\n", stderr);
- }
-
- return result;
-}
-
-void
-xfree (ptr)
- PTR ptr;
-{
- if (debug > 3)
- {
- fputs ("\tfree\tptr = ", stderr);
- fprintf (stderr, HOST_PTR_PRINTF, ptr);
- fputs ("\n", stderr);
- }
-
- free (ptr);
-}
-
/* Define our own index/rindex, since the local and global symbol
structures as defined by MIPS has an 'index' field. */
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 50dde95..9ea38ba 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -630,13 +630,11 @@ lang_init ()
/* If gen_declaration desired, open the output file. */
if (flag_gen_declaration)
{
- int dump_base_name_length = strlen (dump_base_name);
- register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
- strcpy (dumpname, dump_base_name);
- strcat (dumpname, ".decl");
+ register char * const dumpname = concat (dumpname, ".decl", NULL);
gen_declaration_file = fopen (dumpname, "w");
if (gen_declaration_file == 0)
pfatal_with_name (dumpname);
+ free (dumpname);
}
if (flag_next_runtime)
diff --git a/gcc/prefix.c b/gcc/prefix.c
index 8b53d3a..c659c28 100644
--- a/gcc/prefix.c
+++ b/gcc/prefix.c
@@ -282,7 +282,7 @@ translate_name (name)
/* Remove any trailing directory separator from what we got. */
if (IS_DIR_SEPARATOR (prefix[strlen (prefix) - 1]))
{
- char * temp = save_string (prefix, strlen (prefix));
+ char * temp = xstrdup (prefix);
temp[strlen (temp) - 1] = 0;
prefix = temp;
}
@@ -312,28 +312,24 @@ update_path (path, key)
/* Convert DIR_SEPARATOR_2 to DIR_SEPARATOR. */
if (DIR_SEPARATOR != DIR_SEPARATOR_2)
{
- int i;
- int len = strlen (path);
- char *new_path = save_string (path, len);
- for (i = 0; i < len; i++)
- if (new_path[i] == DIR_SEPARATOR_2)
- new_path[i] = DIR_SEPARATOR;
+ char *new_path = xstrdup (path);
path = new_path;
+ do {
+ if (*new_path == DIR_SEPARATOR_2)
+ *new_path = DIR_SEPARATOR;
+ } while (*new_path++);
}
#endif
#if defined (DIR_SEPARATOR) && !defined (DIR_SEPARATOR_2)
if (DIR_SEPARATOR != '/')
{
- int i;
- int len = strlen (path);
- char *new_path = save_string (path, len);
-
- for (i = 0; i < len; i++)
- if (new_path[i] == '/')
- new_path[i] = DIR_SEPARATOR;
-
+ char *new_path = xstrdup (path);
path = new_path;
+ do {
+ if (*new_path == '/')
+ *new_path = DIR_SEPARATOR;
+ } while (*newpath++);
}
#endif
diff --git a/gcc/profile.c b/gcc/profile.c
index 38ed7a7..6a473db 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -563,9 +563,7 @@ branch_prob (f, dump_file)
{
if (last_bb_file_name)
free (last_bb_file_name);
- last_bb_file_name
- = xmalloc (strlen (NOTE_SOURCE_FILE (insn)) + 1);
- strcpy (last_bb_file_name, NOTE_SOURCE_FILE (insn));
+ last_bb_file_name = xstrdup (NOTE_SOURCE_FILE (insn));
output_gcov_string (NOTE_SOURCE_FILE (insn), (long)-1);
}
diff --git a/gcc/protoize.c b/gcc/protoize.c
index 0f1b31a..1c187fc 100644
--- a/gcc/protoize.c
+++ b/gcc/protoize.c
@@ -600,73 +600,6 @@ notice VPARAMS ((const char *msgid, ...))
}
-char *
-xstrerror(e)
- int e;
-{
-
-#ifdef HAVE_STRERROR
- return strerror(e);
-
-#else
- if (!e)
- return "";
-
- if (e > 0 && e < sys_nerr)
- return sys_errlist[e];
-
- return "errno = ?";
-#endif
-}
-
-/* Allocate some space, but check that the allocation was successful. */
-/* alloca.c uses this, so don't make it static. */
-
-pointer_type
-xmalloc (byte_count)
- size_t byte_count;
-{
- register pointer_type rv = (pointer_type) malloc (byte_count);
- if (rv == NULL)
- {
- notice ("\n%s: virtual memory exceeded\n", pname);
- exit (FATAL_EXIT_CODE);
- }
- return rv;
-}
-
-/* Reallocate some space, but check that the reallocation was successful. */
-
-pointer_type
-xrealloc (old_space, byte_count)
- pointer_type old_space;
- size_t byte_count;
-{
- register pointer_type rv;
- if (old_space)
- rv = (pointer_type) realloc (old_space, byte_count);
- else
- rv = (pointer_type) malloc (byte_count);
- if (rv == NULL)
- {
- notice ("\n%s: virtual memory exceeded\n", pname);
- exit (FATAL_EXIT_CODE);
- }
- return rv;
-}
-
-/* Deallocate the area pointed to by an arbitrary pointer, but first, strip
- the `const' qualifier from it and also make sure that the pointer value
- is non-null. */
-
-void
-xfree (p)
- const_pointer_type p;
-{
- if (p)
- free ((NONCONST pointer_type) p);
-}
-
/* Make a copy of a string INPUT with size SIZE. */
static char *
@@ -679,21 +612,6 @@ savestring (input, size)
return output;
}
-/* Make a copy of the concatenation of INPUT1 and INPUT2. */
-
-static char *
-savestring2 (input1, size1, input2, size2)
- const char *input1;
- unsigned int size1;
- const char *input2;
- unsigned int size2;
-{
- char *output = (char *) xmalloc (size1 + size2 + 1);
- strcpy (output, input1);
- strcpy (&output[size1], input2);
- return output;
-}
-
/* More 'friendly' abort that prints the line and file.
config.h can #define abort fancy_abort if you like that sort of thing. */
@@ -1109,7 +1027,7 @@ add_symbol (p, s)
const char *s;
{
p->hash_next = NULL;
- p->symbol = savestring (s, strlen (s));
+ p->symbol = xstrdup (s);
p->ddip = NULL;
p->fip = NULL;
return p;
@@ -1157,7 +1075,7 @@ static void
free_def_dec (p)
def_dec_info *p;
{
- xfree (p->ansi_decl);
+ free ((NONCONST pointer_type) p->ansi_decl);
#ifndef UNPROTOIZE
{
@@ -1167,12 +1085,12 @@ free_def_dec (p)
for (curr = p->f_list_chain; curr; curr = next)
{
next = curr->chain_next;
- xfree (curr);
+ free ((NONCONST pointer_type) curr);
}
}
#endif /* !defined (UNPROTOIZE) */
- xfree (p);
+ free (p);
}
/* Unexpand as many macro symbol as we can find.
@@ -2072,12 +1990,9 @@ gen_aux_info_file (base_filename)
/* Store the full source file name in the argument vector. */
compile_params[input_file_name_index] = shortpath (NULL, base_filename);
/* Add .X to source file name to get aux-info file name. */
- compile_params[aux_info_file_name_index]
- = savestring2 (compile_params[input_file_name_index],
- strlen (compile_params[input_file_name_index]),
- ".X",
- 2);
-
+ compile_params[aux_info_file_name_index] =
+ concat (compile_params[input_file_name_index], ".X", NULL);
+
if (!quiet_flag)
notice ("%s: compiling `%s'\n",
pname, compile_params[input_file_name_index]);
@@ -2382,7 +2297,7 @@ start_over: ;
if (referenced_file_is_newer (aux_info_p, aux_info_mtime))
{
free (aux_info_base);
- xfree (aux_info_relocated_name);
+ free (aux_info_relocated_name);
if (keep_it && my_unlink (aux_info_filename) == -1)
{
int errno_val = errno;
@@ -2431,7 +2346,7 @@ start_over: ;
}
free (aux_info_base);
- xfree (aux_info_relocated_name);
+ free (aux_info_relocated_name);
}
#ifndef UNPROTOIZE
diff --git a/gcc/reload1.c b/gcc/reload1.c
index 2a107e8..a03e810 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -655,27 +655,20 @@ reload (first, global, dumpfile)
Record memory equivalents in reg_mem_equiv so they can
be substituted eventually by altering the REG-rtx's. */
- reg_equiv_constant = (rtx *) xmalloc (max_regno * sizeof (rtx));
- bzero ((char *) reg_equiv_constant, max_regno * sizeof (rtx));
- reg_equiv_memory_loc = (rtx *) xmalloc (max_regno * sizeof (rtx));
- bzero ((char *) reg_equiv_memory_loc, max_regno * sizeof (rtx));
- reg_equiv_mem = (rtx *) xmalloc (max_regno * sizeof (rtx));
- bzero ((char *) reg_equiv_mem, max_regno * sizeof (rtx));
- reg_equiv_init = (rtx *) xmalloc (max_regno * sizeof (rtx));
- bzero ((char *) reg_equiv_init, max_regno * sizeof (rtx));
- reg_equiv_address = (rtx *) xmalloc (max_regno * sizeof (rtx));
- bzero ((char *) reg_equiv_address, max_regno * sizeof (rtx));
- reg_max_ref_width = (int *) xmalloc (max_regno * sizeof (int));
- bzero ((char *) reg_max_ref_width, max_regno * sizeof (int));
- reg_old_renumber = (short *) xmalloc (max_regno * sizeof (short));
+ reg_equiv_constant = (rtx *) xcalloc (max_regno, sizeof (rtx));
+ reg_equiv_memory_loc = (rtx *) xcalloc (max_regno, sizeof (rtx));
+ reg_equiv_mem = (rtx *) xcalloc (max_regno, sizeof (rtx));
+ reg_equiv_init = (rtx *) xcalloc (max_regno, sizeof (rtx));
+ reg_equiv_address = (rtx *) xcalloc (max_regno, sizeof (rtx));
+ reg_max_ref_width = (int *) xcalloc (max_regno, sizeof (int));
+ reg_old_renumber = (short *) xcalloc (max_regno, sizeof (short));
bcopy ((PTR) reg_renumber, (PTR) reg_old_renumber, max_regno * sizeof (short));
pseudo_forbidden_regs
= (HARD_REG_SET *) xmalloc (max_regno * sizeof (HARD_REG_SET));
pseudo_previous_regs
- = (HARD_REG_SET *) xmalloc (max_regno * sizeof (HARD_REG_SET));
+ = (HARD_REG_SET *) xcalloc (max_regno, sizeof (HARD_REG_SET));
CLEAR_HARD_REG_SET (bad_spill_regs_global);
- bzero ((char *) pseudo_previous_regs, max_regno * sizeof (HARD_REG_SET));
/* Look for REG_EQUIV notes; record what each pseudo is equivalent to.
Also find all paradoxical subregs and find largest such for each pseudo.
@@ -3731,12 +3724,8 @@ init_elim_table ()
#endif
if (!reg_eliminate)
- {
- reg_eliminate = (struct elim_table *)
- xmalloc(sizeof(struct elim_table) * NUM_ELIMINABLE_REGS);
- bzero ((PTR) reg_eliminate,
- sizeof(struct elim_table) * NUM_ELIMINABLE_REGS);
- }
+ reg_eliminate = (struct elim_table *)
+ xcalloc(sizeof(struct elim_table), NUM_ELIMINABLE_REGS);
/* Does this function require a frame pointer? */
diff --git a/gcc/resource.c b/gcc/resource.c
index 8802645..4761515 100644
--- a/gcc/resource.c
+++ b/gcc/resource.c
@@ -1167,14 +1167,9 @@ init_resource_info (epilogue_insn)
mark_set_resources (epilogue_insn, &end_of_function_needs, 0, 1);
/* Allocate and initialize the tables used by mark_target_live_regs. */
- target_hash_table
- = (struct target_info **) xmalloc ((TARGET_HASH_PRIME
- * sizeof (struct target_info *)));
- bzero ((char *) target_hash_table,
- TARGET_HASH_PRIME * sizeof (struct target_info *));
-
- bb_ticks = (int *) xmalloc (n_basic_blocks * sizeof (int));
- bzero ((char *) bb_ticks, n_basic_blocks * sizeof (int));
+ target_hash_table = (struct target_info **)
+ xcalloc (TARGET_HASH_PRIME, sizeof (struct target_info *));
+ bb_ticks = (int *) xcalloc (n_basic_blocks, sizeof (int));
}
/* Free up the resources allcated to mark_target_live_regs (). This
diff --git a/gcc/stupid.c b/gcc/stupid.c
index b95e135..41ddcc8 100644
--- a/gcc/stupid.c
+++ b/gcc/stupid.c
@@ -220,36 +220,22 @@ stupid_life_analysis (f, nregs, file)
/* Allocate tables to record info about regs. */
- reg_where_dead = (int *) xmalloc (nregs * sizeof (int));
- bzero ((char *) reg_where_dead, nregs * sizeof (int));
-
- reg_where_born_exact = (int *) xmalloc (nregs * sizeof (int));
- bzero ((char *) reg_where_born_exact, nregs * sizeof (int));
-
- reg_where_born_clobber = (int *) xmalloc (nregs * sizeof (int));
- bzero ((char *) reg_where_born_clobber, nregs * sizeof (int));
-
- reg_where_dead_chain = (struct insn_chain **) xmalloc (nregs * sizeof (struct insn_chain *));
- bzero ((char *) reg_where_dead_chain, nregs * sizeof (struct insn_chain *));
-
- reg_order = (int *) xmalloc (nregs * sizeof (int));
- bzero ((char *) reg_order, nregs * sizeof (int));
-
- regs_change_size = (char *) xmalloc (nregs * sizeof (char));
- bzero ((char *) regs_change_size, nregs * sizeof (char));
-
- regs_crosses_setjmp = (char *) xmalloc (nregs * sizeof (char));
- bzero ((char *) regs_crosses_setjmp, nregs * sizeof (char));
+ reg_where_dead = (int *) xcalloc (nregs, sizeof (int));
+ reg_where_born_exact = (int *) xcalloc (nregs, sizeof (int));
+ reg_where_born_clobber = (int *) xcalloc (nregs, sizeof (int));
+ reg_where_dead_chain = (struct insn_chain **)
+ xcalloc (nregs, sizeof (struct insn_chain *));
+ reg_order = (int *) xcalloc (nregs, sizeof (int));
+ regs_change_size = (char *) xcalloc (nregs, sizeof (char));
+ regs_crosses_setjmp = (char *) xcalloc (nregs, sizeof (char));
/* Allocate the reg_renumber array */
allocate_reg_info (max_regno, FALSE, TRUE);
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
reg_renumber[i] = i;
- after_insn_hard_regs
- = (HARD_REG_SET *) xmalloc (max_suid * sizeof (HARD_REG_SET));
-
- bzero ((char *) after_insn_hard_regs, max_suid * sizeof (HARD_REG_SET));
+ after_insn_hard_regs =
+ (HARD_REG_SET *) xcalloc (max_suid, sizeof (HARD_REG_SET));
/* Allocate and zero out many data structures
that will record the data from lifetime analysis. */
diff --git a/gcc/toplev.c b/gcc/toplev.c
index ca95121..89ed389 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -2280,76 +2280,6 @@ botch (s)
{
abort ();
}
-
-/* Same as `malloc' but report error if no memory available. */
-
-PTR
-xmalloc (size)
- size_t size;
-{
- register PTR value;
-
- if (size == 0)
- size = 1;
-
- value = (PTR) malloc (size);
- if (value == 0)
- fatal ("virtual memory exhausted");
- return value;
-}
-
-/* Same as `calloc' but report error if no memory available. */
-
-PTR
-xcalloc (size1, size2)
- size_t size1, size2;
-{
- register PTR value;
-
- if (size1 == 0 || size2 == 0)
- size1 = size2 = 1;
-
- value = (PTR) calloc (size1, size2);
- if (value == 0)
- fatal ("virtual memory exhausted");
- return value;
-}
-
-
-/* Same as `realloc' but report error if no memory available.
- Also handle null PTR even if the vendor realloc gets it wrong. */
-
-PTR
-xrealloc (ptr, size)
- PTR ptr;
- size_t size;
-{
- register PTR result;
-
- if (size == 0)
- size = 1;
-
- result = (ptr ? (PTR) realloc (ptr, size) : (PTR) malloc (size));
-
- if (!result)
- fatal ("virtual memory exhausted");
-
- return result;
-}
-
-/* Same as `strdup' but report error if no memory available. */
-
-char *
-xstrdup (s)
- register const char *s;
-{
- register char *result = (char *) malloc (strlen (s) + 1);
-
- if (! result)
- fatal ("virtual memory exhausted");
- strcpy (result, s);
- return result;
-}
/* Return the logarithm of X, base 2, considering X unsigned,
if X is a power of 2. Otherwise, returns -1.
@@ -2596,14 +2526,11 @@ open_dump_file (suffix, function_name)
TIMEVAR
(dump_time,
{
- dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
+ dumpname = concat (dump_base_name, suffix, NULL);
if (rtl_dump_file != NULL)
fclose (rtl_dump_file);
- strcpy (dumpname, dump_base_name);
- strcat (dumpname, suffix);
-
rtl_dump_file = fopen (dumpname, "a");
if (rtl_dump_file == NULL)
@@ -2656,13 +2583,8 @@ static void
clean_dump_file (suffix)
const char *suffix;
{
- char *dumpname;
+ char * const dumpname = concat (dump_base_name, suffix, NULL);
- dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1);
-
- strcpy (dumpname, dump_base_name);
- strcat (dumpname, suffix);
-
rtl_dump_file = fopen (dumpname, "w");
if (rtl_dump_file == NULL)
@@ -3103,10 +3025,7 @@ compile_file (name)
strip_off_ending (dumpname, len);
strcat (dumpname, ".s");
if (asm_file_name == 0)
- {
- asm_file_name = (char *) xmalloc (strlen (dumpname) + 1);
- strcpy (asm_file_name, dumpname);
- }
+ asm_file_name = xstrdup (dumpname);
if (!strcmp (asm_file_name, "-"))
asm_out_file = stdout;
else