This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: committed: fix MMIX misuse of ggc_alloc_string


Hans-Peter Nilsson <hp@bitrange.com> writes:
> Index: config/mmix/mmix.c
> ===================================================================
> --- config/mmix/mmix.c	(revision 130341)
> +++ config/mmix/mmix.c	(working copy)
> @@ -1158,14 +1158,11 @@ mmix_encode_section_info (tree decl, rtx
>  
>        const char *str = XSTR (XEXP (rtl, 0), 0);
>        int len = strlen (str);
> -      char *newstr;
> -
> -      /* Why is the return type of ggc_alloc_string const?  */
> -      newstr = CONST_CAST (char *, ggc_alloc_string ("", len + 1));
> -
> +      char *newstr = alloca (len + 2);
> +      newstr[0] = '@';
>        strcpy (newstr + 1, str);
>        *newstr = '@';
> -      XSTR (XEXP (rtl, 0), 0) = newstr;
> +      XSTR (XEXP (rtl, 0), 0) = ggc_alloc_string (newstr, len + 1);
>      }
>  
>    /* Set SYMBOL_REF_FLAG for things that we want to access with GETA.  We
>
> brgds, H-P

FWIW -- and this is just an excuse to plug my favourite macro, so feel
free to ignore -- a more compact, though less efficient, way would be:

    XSTR (XEXP (rtl, 0), 0)
      = ggc_strdup (ACONCAT (("@", XSTR (XEXP (rtl, 0), 0), NULL)));

Richard


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]