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]

RE: [patch] Fix a segfault in h8300 port.


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


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