I've read online that you can free memory in bison like this:
statement:
INTEGER
{
//Do Something
free($1);
}
Where the integer token is returned by flex like this:
[0-9]+ { yylval.integer_value = atoi(yytext); return INTEGER; }
(integer_value is defined as an int)
When I try to free($1)
, I get:
passing argument 1 of ‘free’ makes pointer from integer without a cast
Which makes sense, but I have seen online examples where you can free memory like this. How can I solve this?