help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Leak due to strdup even after using %destructor


From: Hans Aberg
Subject: Re: Memory Leak due to strdup even after using %destructor
Date: Wed, 4 Feb 2009 08:57:11 +0100

On 4 Feb 2009, at 07:40, <address@hidden> <address@hidden > wrote:

           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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]