]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
h8300.c (h8300_encode_label): Compute a string before passing it to ggc_alloc_string.
authorKazu Hirata <kazu@hxi.com>
Thu, 1 Nov 2001 15:40:09 +0000 (15:40 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Thu, 1 Nov 2001 15:40:09 +0000 (15:40 +0000)
* config/h8300/h8300.c (h8300_encode_label): Compute a string
before passing it to ggc_alloc_string.

From-SVN: r46695

gcc/ChangeLog
gcc/config/h8300/h8300.c

index 55f5d46c1d2e9dbdbb4e0d98f2223a9154e4c507..45a62d04750856cac949beff8b646b708c0c6b4e 100644 (file)
@@ -1,3 +1,8 @@
+2001-11-01  Kazu Hirata  <kazu@hxi.com>
+
+       * config/h8300/h8300.c (h8300_encode_label): Compute a string
+       before passing it to ggc_alloc_string.
+
 2001-11-01  Kazu Hirata  <kazu@hxi.com>
 
        * config/m68k/3b1.h: Fix comment formatting.
index c713f522782aa8a5d481b0f0ac1efedf83533648..0d5fffb21f2b41654006cb9f9684346e1878c54f 100644 (file)
@@ -3108,13 +3108,13 @@ h8300_encode_label (decl)
 {
   const char *str = XSTR (XEXP (DECL_RTL (decl), 0), 0);
   int len = strlen (str);
-  char *newstr;
+  char *newstr = alloca (len + 2);
 
-  newstr = ggc_alloc_string (NULL, len + 1);
+  newstr[0] = '&';
+  strcpy (&newstr[1], str);
 
-  strcpy (newstr + 1, str);
-  *newstr = '&';
-  XSTR (XEXP (DECL_RTL (decl), 0), 0) = newstr;
+  XSTR (XEXP (DECL_RTL (decl), 0), 0) =
+    ggc_alloc_string (newstr, len + 1);
 }
 
 const char *