This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [patch] Fix a segfault in h8300 port.
- To: "'law at redhat dot com'" <law at redhat dot com>
- Subject: RE: [patch] Fix a segfault in h8300 port.
- From: Kazu Hirata <kazu at hxi dot com>
- Date: Tue, 30 Oct 2001 09:31:05 -0500
- Cc: gcc-patches at gcc dot gnu dot org
Hi Jeff,
> > 2001-10-29 Kazu Hirata <kazu@hxi.com>
> >
> > * config/h8300/h8300.c (h8300_encode_label): Compute a string
> > before passing it to ggc_alloc_string.
> Err, why do you need to compute the new string before passing it to
> ggc_alloc_string.
>
> Wouldn't fixing the length of the desired string passed to
> ggc_alloc_string fix this problem?
The length of the desired string is correct; it is "strlen (str) + 1",
excluding a terminator.
Since ggc_alloc_string returns a pointer of const char *, I cannot
mess with the pointer in terms of semantics or syntax. In my
understanding, ggc_alloc_string saves memory by not allocating memory
for strings that have occured once in the past, so ggc_alloc_string
needs to know what the string is.
I refered to arm_encode_call_attribute to see how they are using
ggc_alloc_string.
Kazu Hirata