|
| From: | Hans Aberg |
| Subject: | Re: Memory Leak due to strdup even after using %destructor |
| Date: | Wed, 4 Feb 2009 08:57:11 +0100 |
I am new to bison. I got a memory leak. Leak is due to the
strdup in lex file
astr [-a-zA-Z0-9_\.\/\,\<]*
{astr} {
yylval.text = strdup( (char *)yytext );
return ASTR;
}
I have added
%destructor { free($$); } ASTR
but still i am getting memory leaks(valgrind).
can anyone help me how to solve this ???????
%destructor only makes clean-up in the case of errors. So you still need to make normal cleanup in the actions. Or use a language which can do it, like C++ or Java.
Hans
| [Prev in Thread] | Current Thread | [Next in Thread] |