help-bison
[Top][All Lists]
Advanced

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

Re: Different behaviour with string and number tokens ?


From: Arno Wilhelm
Subject: Re: Different behaviour with string and number tokens ?
Date: Tue, 18 Apr 2006 15:02:25 +0200
User-agent: Mozilla Thunderbird 1.0.7-1.1.fc3 (X11/20050929)

Hello,

But I get a memory leak even when I free the the in the bison file like this: WORD EQUAL WORD { $$ = !strncmp( $1, $3, 128 ); free( yylval.str ); }

have found out how to avoid the memory leak myself and thought I would post it 
here
in case somebody runs into the same issue.

One has to free the variables like this:

WORD EQUAL WORD { $$ = !strcmp( $1, $3 ); free($1); free($3); }



regards,
arno




I do not get an error message when compiling but valgrind shows me a leak in the strdup() function:

 > valgrind --leak-check=full rules
...
...
==935== 3 bytes in 1 blocks are definitely lost in loss record 2 of 3
==935==    at 0x401B46D: malloc (vg_replace_malloc.c:149)
==935==    by 0x40D1B9F: strdup (in /lib/tls/libc-2.3.6.so)
==935==    by 0x8048976: yylex (in /RulezParser/flex_bison_test/rules)
==935==    by 0x804990E: yyparse (in /RulezParser/flex_bison_test/rules)
==935==    by 0x804A498: main (in /RulezParser/flex_bison_test/rules)
...

Guess I search the archives and consult the manual before I post a question about this issue -
except somebody here on this list can give me a hint ;-)



thanks,
arno


_______________________________________________
address@hidden http://lists.gnu.org/mailman/listinfo/help-bison






reply via email to

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