X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_Solver.cpp;h=4e7a4f0e9269f7e2d76ad8219a130fce099864f3;hb=20d233731eaae06b9a75280a2ca675bc9a11cc72;hp=650e11c2d79b12c9a261e355c45500c1358acd5d;hpb=bc06873747d5ea9bc0e8d6bd56641eebe33ac08d;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_Solver.cpp b/src/SketchSolver/SketchSolver_Solver.cpp index 650e11c2d..4e7a4f0e9 100644 --- a/src/SketchSolver/SketchSolver_Solver.cpp +++ b/src/SketchSolver/SketchSolver_Solver.cpp @@ -31,6 +31,8 @@ SketchSolver_Solver::SketchSolver_Solver() SketchSolver_Solver::~SketchSolver_Solver() { + if (myEquationsSystem.constraint) + delete[] myEquationsSystem.constraint; if (myEquationsSystem.failed) delete[] myEquationsSystem.failed; } @@ -56,8 +58,18 @@ void SketchSolver_Solver::setEntities(Slvs_Entity* theEntities, int theSize) void SketchSolver_Solver::setConstraints(Slvs_Constraint* theConstraints, int theSize) { - myEquationsSystem.constraint = theConstraints; - myEquationsSystem.constraints = theSize; + if (!myEquationsSystem.constraint) { + myEquationsSystem.constraint = new Slvs_Constraint[theSize]; + myEquationsSystem.constraints = theSize; + } + else if (myEquationsSystem.constraints != theSize) { + if (theSize > myEquationsSystem.constraints) { + delete[] myEquationsSystem.constraint; + myEquationsSystem.constraint = new Slvs_Constraint[theSize]; + } + myEquationsSystem.constraints = theSize; + } + memcpy(myEquationsSystem.constraint, theConstraints, theSize * sizeof(Slvs_Constraint)); }