/* Decreases the reference count on S, which must be an interned string
returned by intern_new(). If the reference count reaches 0, frees the
interned string. */
void
intern_unref (const char *s)
{
/* Decreases the reference count on S, which must be an interned string
returned by intern_new(). If the reference count reaches 0, frees the
interned string. */
void
intern_unref (const char *s)
{
- hmap_delete (&interns, &is->node);
- free (is);
+ struct interned_string *is = interned_string_from_string (s);
+ if (--is->ref_cnt == 0)
+ {
+ hmap_delete (&interns, &is->node);
+ free (is);
+ }