Is there really only one symbol_ref object referring to each symbolic label?

Kazu Hirata kazu@cs.umass.edu
Sun Jun 29 05:43:00 GMT 2003


Hi Zack,

> ggc_strdup is a macro wrapper for ggc_alloc_string, and
> ggc_alloc_string does NOT guarantee the uniqueness of the strings it
> returns.  (However, I consider this a bug in ggc_alloc_string, not in
> its callers.  At one time ggc_alloc_string did uniquize strings - I
> don't know when that got changed or why.)

I was just playing with ggc_alloc_string and noticed the same.  When
gcc was put into cvs, ggc_alloc_string was in ggc-page.c and looked
like so.  I haven't found any trail of uniquization.  Should we start
using htab_*?

char *
ggc_alloc_string (contents, length)
     const char *contents;
     int length;
{
  char *string;

  if (length < 0)
    {
      if (contents == NULL)
	return NULL;
      length = strlen (contents);
    }

  string = (char *) alloc_obj (length + 1, 0);
  if (contents != NULL)
    memcpy (string, contents, length);
  string[length] = 0;

  return string;
}

Kazu Hirata



More information about the Gcc mailing list