[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: calc++ example leaks
From: |
Paul Eggert |
Subject: |
Re: calc++ example leaks |
Date: |
Mon, 11 Sep 2006 11:03:52 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
"Sander Brandenburg" <address@hidden> writes:
> Below is a fix for the memory leaks. I'm only not sure the way I solve it is
> good practice, because keeping track of what needs to be deleted looks
> rather cumbersome.
Thanks for the bug report. Yes, it is cumbersome, but I'm afraid that
for Bison right now that's life in the C++ city. I installed this
patch to fix the upstream source (and some minor white space and
comment issues):
2006-09-11 Paul Eggert <address@hidden>
* doc/bison.texinfo (Calc++ Parser): Fix memory leak reported by
Sander Brandenburg in
<http://lists.gnu.org/archive/html/bug-bison/2006-09/msg00002.html>.
Also, fix minor white space and comment issues.
--- doc/bison.texinfo.~1.203.~ 2006-09-11 10:48:45.000000000 -0700
+++ doc/bison.texinfo 2006-09-11 10:53:30.000000000 -0700
@@ -7423,8 +7423,8 @@ factor both as follows.
@comment file: calc++-driver.hh
@example
-// Announce to Flex the prototype we want for lexing function, ...
-# define YY_DECL \
+// Tell Flex the lexer's prototype ...
+# define YY_DECL \
yy::calcxx_parser::token_type \
yylex (yy::calcxx_parser::semantic_type* yylval, \
yy::calcxx_parser::location_type* yylloc, \
@@ -7675,7 +7675,9 @@ unit: assignments exp @{ driver.result
assignments: assignments assignment @address@hidden
| /* Nothing. */ @address@hidden;
-assignment: "identifier" ":=" exp @{ driver.variables[*$1] = $3; @};
+assignment:
+ "identifier" ":=" exp
+ @{ driver.variables[*$1] = $3; delete $1; @};
%left '+' '-';
%left '*' '/';
@@ -7683,7 +7685,7 @@ exp: exp '+' exp @{ $$ = $1 + $3; @}
| exp '-' exp @{ $$ = $1 - $3; @}
| exp '*' exp @{ $$ = $1 * $3; @}
| exp '/' exp @{ $$ = $1 / $3; @}
- | "identifier" @{ $$ = driver.variables[*$1]; @}
+ | "identifier" @{ $$ = driver.variables[*$1]; delete $1; @}
| "number" @{ $$ = $1; @};
%%
@end example
@@ -7844,8 +7846,8 @@ main (int argc, char *argv[])
driver.trace_scanning = true;
else
@{
- driver.parse (*argv);
- std::cout << driver.result << std::endl;
+ driver.parse (*argv);
+ std::cout << driver.result << std::endl;
@}
@}
@end example
- Re: calc++ example leaks,
Paul Eggert <=