unsigned, int, int, int, int));
void dump_roots P_ ((FILE *));
void *xmalloc P_ ((int));
+void xfree P_ ((void *));
void add_global_defn P_ ((char *, char *, int, unsigned, int, int, int));
void add_global_decl P_ ((char *, char *, int, unsigned, int, int, int));
void add_define P_ ((char *, char *, int));
}
+/* Like free but always check for null pointers.. */
+
+void
+xfree (p)
+ void *p;
+{
+ if (p)
+ free (p);
+}
+
+
/* Like strdup, but print an error and exit if not enough memory is
available.. If S is null, return null. */
break;
case IDENT:
- /* Remember IDENTS seen so far. Among these will be the member
- name. */
- id = (char *) alloca (strlen (yytext) + 2);
+ /* Remember IDENTS seen so far. Among these will be the member
+ name. */
+ id = (char *) xrealloc (id, strlen (yytext) + 2);
if (tilde)
{
*id = '~';
break;
case OPERATOR:
- id = operator_name (&sc);
+ {
+ char *s = operator_name (&sc);
+ id = (char *) xrealloc (id, strlen (s) + 1);
+ strcpy (id, s);
+ }
break;
case '(':
if (LOOKING_AT ('{') && id && cls)
add_member_defn (cls, id, regexp, pos, hash, 0, sc, flags);
-
+
+ xfree (id);
id = NULL;
sc = SC_MEMBER;
break;
skip_matching ();
print_info ();
}
+
+ xfree (id);
}
/* This is for the case `STARTWRAP class X : ...' or
`declare (X, Y)\n class A : ...'. */
if (id)
- return;
+ {
+ xfree (id);
+ return;
+ }
case '=':
/* Assumed to be the start of an initialization in this context.
break;
case OPERATOR:
- id = operator_name (&sc);
+ {
+ char *s = operator_name (&sc);
+ id = (char *) xrealloc (id, strlen (s) + 1);
+ strcpy (id, s);
+ }
break;
case T_INLINE:
MATCH ();
if (LOOKING_AT (IDENT))
{
- id = (char *) alloca (strlen (yytext) + 2);
+ id = (char *) xrealloc (id, strlen (yytext) + 2);
*id = '~';
strcpy (id + 1, yytext);
MATCH ();
if (!cls && id && LOOKING_AT ('{'))
add_global_defn (id, regexp, pos, hash, 0, sc, flags);
+
+ xfree (id);
id = NULL;
break;
}
skip_matching ();
print_info ();
}
+
+ xfree (id);
}
if (LOOKING_AT (IDENT))
{
- char *namespace_name
- = (char *) alloca (strlen (yytext) + 1);
- strcpy (namespace_name, yytext);
+ char *namespace_name = xstrdup (yytext);
MATCH ();
if (LOOKING_AT ('='))
leave_namespace ();
MATCH_IF ('}');
}
+
+ xfree (namespace_name);
}
}
break;