|
From: | Hans Aberg |
Subject: | Re: Memory leak in bison-generated code |
Date: | Fri, 6 Feb 2009 22:48:07 +0100 |
On 6 Feb 2009, at 17:54, Jean Delvare wrote:
Valgrind tells me that there's a memory leak in libsensors [1], in codewhich is generated by flex/bison:
...
I upgraded to bison 2.4.1. Alas, the memory leak is still there, and asa matter of fact I don't see any call to yylex_destroy() in the generated code. If I do call sensors_yylex_destroy() manually then the memory leak goes away.
Bison is just a parser generator, and though it should be synced with Flex, it is a different project, and things like lexer allocation/ deallocation must be handled by hand or within the lexer (your leaks looks being within the lexer). Since the problem goes away if you call sensors_yylex_destroy() manually, it might be a Bison documentation problem.
On the other hand, a FAQ is figuring out how to do token allocation, and then, when using C, one has to deallocate it by hand in every rule. So if you have ideas to fix it, you might report it on the Bug- Bison list.
Hans
[Prev in Thread] | Current Thread | [Next in Thread] |