diff options
author | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-09-07 02:36:41 +0000 |
---|---|---|
committer | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-09-07 02:36:41 +0000 |
commit | 713829e97b2cabe9369424002f6efb23a7c86aba (patch) | |
tree | 4078f3a9721ec2407abe016bdfff56e653a05da4 /gcc/gcc.c | |
parent | da7052f68ce6c63c9b86c438a016f6052f2e8613 (diff) | |
download | gcc-713829e97b2cabe9369424002f6efb23a7c86aba.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@29148 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r-- | gcc/gcc.c | 85 |
1 files changed, 12 insertions, 73 deletions
diff --git a/gcc/gcc.c b/gcc/gcc.c index c01f2bd6e29..e85b8a9a5ca 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; |