sofa
sofa copied to clipboard
[objectmodel] Remove memory leaks
The following code create memory leaks:
static const BaseClass* get()
{
static TClass<T, Parents> *theClass=new TClass<T, Parents>();
return theClass;
}
To remove the memory leak, it has to be replaced by:
static const BaseClass* get()
{
static TClass<T, Parents> theClass;
return &theClass;
}
However, Parents can be a std::pair, which one of the pair type can be an abstract type. Since it is not possible to instantiate an abstract type, the compilation fails.
This PR removes the use of std::pair to introduce a structure that does not need to instantiate the types. The compilation now succeeds.
By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).
Reviewers will merge this pull-request only if
- it builds with SUCCESS for all platforms on the CI.
- it does not generate new warnings.
- it does not generate new unit test failures.
- it does not generate new scene test failures.
- it does not break API compatibility.
- it is more than 1 week old (or has fast-merge label).
[ci-build][with-all-tests]
@JeremieA it may be of interest
@sofa-framework/reviewers will be merged next week