-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix some memory leaks for parsing & cleaning up rules #2580
Conversation
great for "delete transformations" |
@@ -80,6 +80,10 @@ RuleWithActions::RuleWithActions( | |||
m_containsStaticBlockAction(false), | |||
m_isChained(false) { | |||
|
|||
if (transformations != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just understand. It's the same like delete actions
do.
@zimmerle What is holding you back from merging this? I also have a problem with these memory leaks, it would be great to merge it. ;) |
@@ -129,9 +129,9 @@ int Driver::parse(const std::string &f, const std::string &ref) { | |||
m_lastRule = nullptr; | |||
loc.push_back(new yy::location()); | |||
if (ref.empty()) { | |||
loc.back()->begin.filename = loc.back()->end.filename = new std::string("<<reference missing or not informed>>"); | |||
loc.back()->begin.filename = loc.back()->end.filename = std::shared_ptr<const std::string>(new std::string("<<reference missing or not informed>>")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using std::make_shared
to avoid using new
loc.back()->begin.filename = loc.back()->end.filename = std::shared_ptr<const std::string>(new std::string("<<reference missing or not informed>>")); | |
loc.back()->begin.filename = loc.back()->end.filename = std::make_shared<const std::string>("<<reference missing or not informed>>"); |
@@ -129,9 +129,9 @@ int Driver::parse(const std::string &f, const std::string &ref) { | |||
m_lastRule = nullptr; | |||
loc.push_back(new yy::location()); | |||
if (ref.empty()) { | |||
loc.back()->begin.filename = loc.back()->end.filename = new std::string("<<reference missing or not informed>>"); | |||
loc.back()->begin.filename = loc.back()->end.filename = std::shared_ptr<const std::string>(new std::string("<<reference missing or not informed>>")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using std::make_shared
to avoid using new
loc.back()->begin.filename = loc.back()->end.filename = std::shared_ptr<const std::string>(new std::string("<<reference missing or not informed>>")); | |
loc.back()->begin.filename = loc.back()->end.filename = std::make_shared<const std::string>("<<reference missing or not informed>>"); |
I don't believe the portions of this PR related to filename are correct. The problem is that location.hh is a generated file. The manual change to that file suggested in this PR could be made and a build done. But thereafter, any time bison rebuilt the generated files, those manual changes would be lost. I'll go ahead and commit the other two fixes via a separate PR:
The parser-filename issue can be addressed later via a separate issue or PR. |
No description provided.