Re: Memory leak in flex generated file

John Millaway <johnmillaway@yahoo.com>
29 Oct 2005 21:28:34 -0400

          From comp.compilers

Related articles
[2 earlier articles]
Re: Memory leak in flex generated file gneuner2@comcast.net (George Neuner) (2005-10-23)
Re: Memory leak in flex generated file johnmillaway@yahoo.com (John Millaway) (2005-10-26)
Re: Memory leak in flex generated file Markus.Elfring@web.de (2005-10-26)
Re: Memory leak in flex generated file haberg@math.su.se (2005-10-27)
Re: Memory leak in flex generated file haberg@math.su.se (2005-10-27)
Re: Memory leak in flex generated file johnmillaway@yahoo.com (John Millaway) (2005-10-27)
Re: Memory leak in flex generated file johnmillaway@yahoo.com (John Millaway) (2005-10-29)
Memory leak in flex generated file pierreir@look.ca (Pierre Innocent) (2007-08-20)
Re: Memory leak in flex generated file jnvolkov@gmail.com (commander) (2007-08-21)
| List of all articles for this month |
From: John Millaway <johnmillaway@yahoo.com>
Newsgroups: comp.compilers
Date: 29 Oct 2005 21:28:34 -0400
Organization: Compilers Central
References: 05-10-151
Keywords: lex, storage
Posted-Date: 29 Oct 2005 21:28:34 EDT

Just so we're clear. There is no memory leak in the flex generated
scanner. There used to be a leak. I fixed it years ago. Don't take my
word for it, here's the code:


/* yylex_destroy is for both reentrant and non-reentrant scanners. */
int yylex_destroy (void)
{
        /* Pop the buffer stack, destroying each element. */
        while (YY_CURRENT_BUFFER){
                yy_delete_buffer (YY_CURRENT_BUFFER );
                YY_CURRENT_BUFFER_LVALUE = NULL;
                yypop_buffer_state ();
        }


        /* Destroy the stack itself. */
        yyfree ( yy_buffer_stack );
        yy_buffer_stack = NULL;


        /* Destroy the start condition stack. */
        yyfree ( yy_start_stack );
        yy_start_stack = NULL;
        return 0;
}


-Millaway


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.