From 93cacb72d049165e92864ef505cf2f936cc33af3 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 1 Nov 2001 15:40:09 +0000 Subject: [PATCH] h8300.c (h8300_encode_label): Compute a string before passing it to ggc_alloc_string. * config/h8300/h8300.c (h8300_encode_label): Compute a string before passing it to ggc_alloc_string. From-SVN: r46695 --- gcc/ChangeLog | 5 +++++ gcc/config/h8300/h8300.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 55f5d46c1d2..45a62d04750 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2001-11-01 Kazu Hirata + + * config/h8300/h8300.c (h8300_encode_label): Compute a string + before passing it to ggc_alloc_string. + 2001-11-01 Kazu Hirata * config/m68k/3b1.h: Fix comment formatting. diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index c713f522782..0d5fffb21f2 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -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 *