mirror of https://github.com/stella-emu/stella.git
![]() However, we do leak memory: yyparse() happily allocates Expressions as it parses, but when it hits a parse error, it doesn't return a valid pointer to the top of the Expression tree. From what I can tell, the so-called Expression* result is the int value of the last lexer token cast to an Expression* (due to yacc's use of a union). I know how to avoid the leak: we need to keep a vector of Expression pointers in YaccParser. If there's a parse error, yyerror() can delete all the Expressions using the vector. If not, we clear the vector (er, calling .clear() on a vector doesn't delete all its elements, too, does it?). Every time yacc says "$$ = new WhateverExpression", it also should vector.push_back($$). Will implement this tomorrow; am getting tired & flaky. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@655 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba |
||
---|---|---|
CVSROOT | ||
stella |