Hi everybody,
I have have a question concerning memory allocation for yyval in bison:
I' looking for the memory reserved for yyval, how it is done and how
much it is. In the .c-file generated by bison, I found yyval is of the
type YYSTYPE. But I cannot find any information about the memory. Also,
I found no about it in the help archive.
What it is all about:
My parser is working direct on the bison-made variables (all those $$,
$1...). It's like this:
{...
strcat($1, $2);
$$ = $1;
...}
Up to now, I had no problems with this. But I'm not sure: is it right to
extend $1 this way, or am I doing some real big-memory-chaos-thing?
Is it wiser to do it this way:
{...
char *temp = malloc( (3+strlen($1)) );
strcat(temp , $2);
$$ = temp;
...}
In fact I'm just starting with flex and bison, and even with C, so I'm
sorry if this is a stupid question.
Regards and thanks,
Martin Bock
_______________________________________________
[email protected] http://lists.gnu.org/mailman/listinfo/help-bison