From 284a7b54530ebcd2e1027fe7dd831049e8a8b6f0 Mon Sep 17 00:00:00 2001 From: ghazi Date: Mon, 23 Apr 2001 00:36:28 +0000 Subject: [PATCH] * collect2.c (main): Use concat in lieu of xmalloc/sprintf. (write_c_file_stat): Likewise. * dbxout.c (dbxout_init): Likewise. * profile.c (output_func_start_profiler): Likewise. cp: * xref.c (GNU_xref_file): Use concat in lieu of xmalloc/sprintf. f: * com.c (ffecom_subscript_check_): Use concat in lieu of xmalloc/sprintf. java: * jvspec.c (lang_specific_driver): Fix memory allocation deficit, by using concat in lieu of xmalloc/sprintf. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@41495 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 9 +++++++++ gcc/collect2.c | 29 ++++++----------------------- gcc/cp/ChangeLog | 4 ++++ gcc/cp/xref.c | 9 +-------- gcc/dbxout.c | 6 +----- gcc/f/ChangeLog | 5 +++++ gcc/f/com.c | 17 ++++++----------- gcc/java/ChangeLog | 5 +++++ gcc/java/jvspec.c | 10 ++-------- gcc/profile.c | 3 +-- 10 files changed, 40 insertions(+), 57 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 97cb9411bce..f2a7a3d3ec3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2001-04-22 Kaveh R. Ghazi + + * collect2.c (main): Use concat in lieu of xmalloc/sprintf. + (write_c_file_stat): Likewise. + + * dbxout.c (dbxout_init): Likewise. + + * profile.c (output_func_start_profiler): Likewise. + 2001-04-22 Philipp Thomas * ABOUT-GCC-NLS: Now that gettext 0.10.37 is out, diff --git a/gcc/collect2.c b/gcc/collect2.c index 63ec00dacfd..4757b9fb688 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -1269,9 +1269,8 @@ main (argc, argv) if (exports.first) { - char *buf = xmalloc (strlen (export_file) + 5); - - sprintf (buf, "-bE:%s", export_file); + char *buf = concat ("-bE:", export_file, NULL); + *ld1++ = buf; *ld2++ = buf; @@ -1435,13 +1434,7 @@ main (argc, argv) /* Tell the linker that we have initializer and finalizer functions. */ #ifdef LD_INIT_SWITCH #ifdef COLLECT_EXPORT_LIST - { - /* option name + functions + colons + NULL */ - char *buf = xmalloc (strlen (LD_INIT_SWITCH) - + strlen(initname) + strlen(fininame) + 3); - sprintf (buf, "%s:%s:%s", LD_INIT_SWITCH, initname, fininame); - *ld2++ = buf; - } + *ld2++ = concat (LD_INIT_SWITCH, ":", initname, ":", fininame, NULL); #else *ld2++ = LD_INIT_SWITCH; *ld2++ = initname; @@ -1456,12 +1449,7 @@ main (argc, argv) /* If we did not add export flag to link arguments before, add it to second link phase now. No new exports should have been added. */ if (! exports.first) - { - char *buf = xmalloc (strlen (export_file) + 5); - - sprintf (buf, "-bE:%s", export_file); - *ld2++ = buf; - } + *ld2++ = concat ("-bE:", export_file, NULL); add_to_list (&exports, initname); add_to_list (&exports, fininame); @@ -1878,13 +1866,8 @@ write_c_file_stat (stream, name) notice ("\nwrite_c_file - output name is %s, prefix is %s\n", output_file, prefix); -#define INIT_NAME_FORMAT "_GLOBAL__FI_%s" - initname = xmalloc (strlen (prefix) + sizeof (INIT_NAME_FORMAT) - 2); - sprintf (initname, INIT_NAME_FORMAT, prefix); - -#define FINI_NAME_FORMAT "_GLOBAL__FD_%s" - fininame = xmalloc (strlen (prefix) + sizeof (FINI_NAME_FORMAT) - 2); - sprintf (fininame, FINI_NAME_FORMAT, prefix); + initname = concat ("_GLOBAL__FI_", prefix, NULL); + fininame = concat ("_GLOBAL__FD_", prefix, NULL); free (prefix); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d8273302194..31019b26faf 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2001-04-22 Kaveh R. Ghazi + + * xref.c (GNU_xref_file): Use concat in lieu of xmalloc/sprintf. + 2001-04-23 Jason Merrill * except.c (build_throw): Wrap the initialization of the exception diff --git a/gcc/cp/xref.c b/gcc/cp/xref.c index cf99fcd400b..af35020efb8 100644 --- a/gcc/cp/xref.c +++ b/gcc/cp/xref.c @@ -205,14 +205,7 @@ GNU_xref_file (name) if (FILE_NAME_ABSOLUTE_P (name) || ! wd_name) xf->outname = xf->name; else - { - char *nmbuf - = (char *) xmalloc (strlen (wd_name) + strlen (FILE_NAME_JOINER) - + strlen (name) + 1); - sprintf (nmbuf, "%s%s%s", wd_name, FILE_NAME_JOINER, name); - name = nmbuf; - xf->outname = nmbuf; - } + xf->outname = name = concat (wd_name, FILE_NAME_JOINER, name, NULL); fprintf (xref_file, "FIL %s %s 0\n", name, wd_name); diff --git a/gcc/dbxout.c b/gcc/dbxout.c index 31c859676e9..1252e2b5cd1 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -395,11 +395,7 @@ dbxout_init (asm_file, input_file_name, syms) #endif { if (!cwd && (cwd = getpwd ()) && (!*cwd || cwd[strlen (cwd) - 1] != '/')) - { - char *wdslash = xmalloc (strlen (cwd) + sizeof (FILE_NAME_JOINER)); - sprintf (wdslash, "%s%s", cwd, FILE_NAME_JOINER); - cwd = wdslash; - } + cwd = concat (cwd, FILE_NAME_JOINER, NULL); if (cwd) { #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog index 5a9c6fe5fef..f4ceb1c5cb1 100644 --- a/gcc/f/ChangeLog +++ b/gcc/f/ChangeLog @@ -1,3 +1,8 @@ +Sun Apr 22 20:18:01 2001 Kaveh R. Ghazi + + * com.c (ffecom_subscript_check_): Use concat in lieu of + xmalloc/sprintf. + 2001-04-21 Toon Moene * news.texi: Update release information for 0.5.27. diff --git a/gcc/f/com.c b/gcc/f/com.c index 52843e3ab25..87d63f01e8d 100644 --- a/gcc/f/com.c +++ b/gcc/f/com.c @@ -694,10 +694,8 @@ ffecom_subscript_check_ (tree array, tree element, int dim, int total_dims, switch (total_dims) { case 0: - var = xmalloc (strlen (array_name) + 20); - sprintf (var, "%s[%s-substring]", - array_name, - dim ? "end" : "start"); + var = concat (array_name, "[", (dim ? "end" : "start"), + "-substring]", NULL); len = strlen (var) + 1; arg1 = build_string (len, var); free (var); @@ -740,13 +738,10 @@ ffecom_subscript_check_ (tree array, tree element, int dim, int total_dims, convert (TREE_TYPE (element), integer_one_node))); - proc = xmalloc ((len = strlen (input_filename) - + IDENTIFIER_LENGTH (DECL_NAME (current_function_decl)) - + 2)); - - sprintf (&proc[0], "%s/%s", - input_filename, - IDENTIFIER_POINTER (DECL_NAME (current_function_decl))); + proc = concat (input_filename, "/", + IDENTIFIER_POINTER (DECL_NAME (current_function_decl)), + NULL); + len = strlen (proc) + 1; arg3 = build_string (len, proc); free (proc); diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index d6af9b30ba0..43c5d49995a 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,8 @@ +2001-04-22 Kaveh R. Ghazi + + * jvspec.c (lang_specific_driver): Fix memory allocation + deficit, by using concat in lieu of xmalloc/sprintf. + 2001-04-20 Per Bothner Fixes to compile multiple .class files at once. diff --git a/gcc/java/jvspec.c b/gcc/java/jvspec.c index 105f8133c56..fd6ec5aab92 100644 --- a/gcc/java/jvspec.c +++ b/gcc/java/jvspec.c @@ -436,20 +436,14 @@ lang_specific_driver (in_argc, in_argv, in_added_libraries) if (strcmp (argv[i], "-classpath") == 0 || strcmp (argv[i], "-CLASSPATH") == 0) { - char* patharg - = (char*) xmalloc (strlen (argv[i]) + strlen (argv[i+1]) + 3); - sprintf (patharg, "-f%s=%s", argv[i]+1, argv[i+1]); - arglist[j] = patharg; + arglist[j] = concat ("-f", argv[i]+1, "=", argv[i+1], NULL); i++; continue; } if (strcmp (argv[i], "-d") == 0) { - char *patharg = (char *) xmalloc (sizeof ("-foutput-class-dir=") - + strlen (argv[i + 1]) + 1); - sprintf (patharg, "-foutput-class-dir=%s", argv[i + 1]); - arglist[j] = patharg; + arglist[j] = concat ("-foutput-class-dir=", argv[i + 1], NULL); ++i; continue; } diff --git a/gcc/profile.c b/gcc/profile.c index 7b5169c8d37..52253082aa5 100644 --- a/gcc/profile.c +++ b/gcc/profile.c @@ -1090,8 +1090,7 @@ output_func_start_profiler () fnname = get_file_function_name ('I'); cfnname = IDENTIFIER_POINTER (fnname); - name = xmalloc (strlen (cfnname) + 5); - sprintf (name, "%sGCOV",cfnname); + name = concat (cfnname, "GCOV", NULL); fnname = get_identifier (name); free (name); -- 2.11.4.GIT