I have a multithreaded application and was testing my mock code for memory leaks. Running the code below results in rapid memory growth of the application.
It was my understanding that calling yy_delete_buffer(buf, scanner) and subsequently yylex_destroy(scanner) would be all I need to do to free up the memory? Any help would be greatly appreciated. Thanks! flex.l: %{ #include <stdlib.h> #include <string.h> #include "yacc.tab.h" %} %option reentrant %option bison-bridge %% [\\&] return AMP; [[:alnum:]]+ yylval->strval=strdup(yytext); return TOK_WORD; [=] return EQ; ^[\\?] return QM; yacc.y: %{ typedef struct yy_buffer_state *YY_BUFFER_STATE; extern YY_BUFFER_STATE yy_scan_string(const char *, void *); extern void yy_delete_buffer(YY_BUFFER_STATE, void *); void yyerror(void *, char *); %} %union { u_node *node; char *strval; }; %pure-parser %lex-param {void *scanner} %parse-param {void *scanner} %token <strval> TOK_WORD AMP EQ QM %type <node> pair %% grammar : QM pair; pair : TOK_WORD EQ TOK_WORD | TOK_WORD EQ TOK_WORD AMP pair ; %% int main(void) { char string[50] = "?key=value&key2=value2"; void *scanner; while(1) { yylex_init(&scanner); YY_BUFFER_STATE buffer = yy_scan_string(string, scanner); yyparse(scanner); yy_delete_buffer(buffer, scanner); yylex_destroy(scanner); } return 0; } int yywrap(void) { return 1; } void yyerror(void *scanner, char *s) { fprintf(stderr, "Error: %s\n", s); } _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison