mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[solver] Fix memory leak: the static hierarchy and dynamic hierarchy
used to clone the operands given as parameters.
This commit is contained in:
@@ -237,13 +237,13 @@ EquationStore::Error EquationStore::oneDimensialPolynomialSolve(Expression * exa
|
||||
Expression::Simplify(&delta, *context);
|
||||
if (delta->isRationalZero()) {
|
||||
// if delta = 0, x0=x1= -b/(2a)
|
||||
exactSolutions[0] = new Division(new Opposite(coefficients[1], false), new Multiplication(new Rational(2), coefficients[2]), false);
|
||||
exactSolutions[0] = new Division(new Opposite(coefficients[1], false), new Multiplication(new Rational(2), coefficients[2], false), false);
|
||||
m_numberOfSolutions = 1;
|
||||
} else {
|
||||
// x0 = (-b-sqrt(delta))/(2a)
|
||||
exactSolutions[0] = new Division(new Subtraction(new Opposite(coefficients[1]->clone(), false), new SquareRoot(delta->clone(), false), false), new Multiplication(new Rational(2), coefficients[2]->clone()), false);
|
||||
exactSolutions[0] = new Division(new Subtraction(new Opposite(coefficients[1]->clone(), false), new SquareRoot(delta->clone(), false), false), new Multiplication(new Rational(2), coefficients[2]->clone(), false), false);
|
||||
// x1 = (-b+sqrt(delta))/(2a)
|
||||
exactSolutions[1] = new Division(new Addition(new Opposite(coefficients[1], false), new SquareRoot(delta->clone(), false), false), new Multiplication(new Rational(2), coefficients[2]), false);
|
||||
exactSolutions[1] = new Division(new Addition(new Opposite(coefficients[1], false), new SquareRoot(delta->clone(), false), false), new Multiplication(new Rational(2), coefficients[2], false), false);
|
||||
m_numberOfSolutions = 2;
|
||||
}
|
||||
exactSolutions[m_numberOfSolutions] = delta;
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace Poincare {
|
||||
class DynamicHierarchy : public Expression {
|
||||
public:
|
||||
DynamicHierarchy();
|
||||
DynamicHierarchy(const Expression * const * operands, int numberOfOperands, bool cloneOperands = true);
|
||||
DynamicHierarchy(const Expression * operand1, const Expression * operand2, bool cloneOperands = true) :
|
||||
DynamicHierarchy(const Expression * const * operands, int numberOfOperands, bool cloneOperands);
|
||||
DynamicHierarchy(const Expression * operand1, const Expression * operand2, bool cloneOperands) :
|
||||
DynamicHierarchy(ExpressionArray(operand1, operand2).array(), 2, cloneOperands) {}
|
||||
~DynamicHierarchy();
|
||||
DynamicHierarchy(const DynamicHierarchy & other) = delete;
|
||||
|
||||
@@ -10,8 +10,8 @@ template<int T>
|
||||
class StaticHierarchy : public Expression {
|
||||
public:
|
||||
StaticHierarchy();
|
||||
StaticHierarchy(const Expression * const * operands, bool cloneOperands = true);
|
||||
StaticHierarchy(const Expression * expression, bool cloneOperands = true); // Specialized constructor for StaticHierarchy<1>
|
||||
StaticHierarchy(const Expression * const * operands, bool cloneOperands);
|
||||
StaticHierarchy(const Expression * expression, bool cloneOperands); // Specialized constructor for StaticHierarchy<1>
|
||||
StaticHierarchy(const Expression * expression1, const Expression * expression2, bool cloneOperands = true); // Specialized constructor for StaticHierarchy<2>
|
||||
~StaticHierarchy();
|
||||
StaticHierarchy(const StaticHierarchy & other) = delete;
|
||||
|
||||
Reference in New Issue
Block a user