Memory leak fix and general improvements of FGDistributor#1245
Merged
agodemar merged 2 commits intoJSBSim-Team:masterfrom Mar 17, 2025
Merged
Memory leak fix and general improvements of FGDistributor#1245agodemar merged 2 commits intoJSBSim-Team:masterfrom
FGDistributor#1245agodemar merged 2 commits intoJSBSim-Team:masterfrom
Conversation
…so constified some methods of `FGDistributor` and `FGCondition`.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1245 +/- ##
=======================================
Coverage 24.77% 24.77%
=======================================
Files 169 169
Lines 19425 19421 -4
=======================================
Hits 4812 4812
+ Misses 14613 14609 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bcoconni
added a commit
to bcoconni/jsbsim
that referenced
this pull request
Mar 21, 2025
bcoconni
added a commit
to bcoconni/jsbsim
that referenced
this pull request
Mar 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a follow up of PR #1244: the destructor
FGDistributor::Case::~Caseis not deleting its memberTestbecause the call todelete Testis missing. It should have been:~Case() { for (auto pair: PropValPairs) delete pair; + delete Test; }Given this and the leak that has been fixed in PR #1244, this PR is addressing the issue upfront and replaces all pointers in
FGDistributorby smart pointers (namelystd::unique_ptr<>) which should fix all sources of memory leakage inFGDistributor.The opportunity is taken to rename the iterator methods of the class
FGDistributor::CasefromIterPropValPairs,EndPropValPairsto the standardized namesbegin,end. This allows using a for-range loop instead of an explicitforloop:which is easier to read.
Finally, the methods
FGCondition::EvaluateandFGCondition::PrintConditionare constified to ensure that they are not having side effects on the instances of the classFGDistributor::Case.Please note that the class
FGDistributor::Caseis private toFGDistributorand modifying its API has no side effects beyond the internal code ofFGDistributor.