diff options
author | Gael Guennebaud <g.gael@free.fr> | 2011-03-19 01:06:50 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2011-03-19 01:06:50 +0100 |
commit | 290205dfc049abc5a92c1191740b30fa91130ade (patch) | |
tree | 0d07fea8597fb5d7f023a23cce7cb0b240be84c2 /Eigen/src/Core/products/TriangularSolverMatrix.h | |
parent | 5991d247f9b167ed738ef95ead0b5ee9a0248edd (diff) |
fix memory leak when a custom scalar throw an exception
Diffstat (limited to 'Eigen/src/Core/products/TriangularSolverMatrix.h')
-rw-r--r-- | Eigen/src/Core/products/TriangularSolverMatrix.h | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/Eigen/src/Core/products/TriangularSolverMatrix.h b/Eigen/src/Core/products/TriangularSolverMatrix.h index 8b9143c2b..a6ad9c322 100644 --- a/Eigen/src/Core/products/TriangularSolverMatrix.h +++ b/Eigen/src/Core/products/TriangularSolverMatrix.h @@ -70,10 +70,10 @@ struct triangular_solve_matrix<Scalar,Index,OnTheLeft,Mode,Conjugate,TriStorageO Index nc = cols; // cache block size along the N direction computeProductBlockingSizes<Scalar,Scalar,4>(kc, mc, nc); - Scalar* blockA = ei_aligned_stack_new(Scalar, kc*mc); std::size_t sizeW = kc*Traits::WorkSpaceFactor; std::size_t sizeB = sizeW + kc*cols; - Scalar* allocatedBlockB = ei_aligned_stack_new(Scalar, sizeB); + ei_declare_aligned_stack_constructed_variable(Scalar, blockA, kc*mc, 0); + ei_declare_aligned_stack_constructed_variable(Scalar, allocatedBlockB, sizeB, 0); Scalar* blockB = allocatedBlockB + sizeW; conj_if<Conjugate> conj; @@ -174,9 +174,6 @@ struct triangular_solve_matrix<Scalar,Index,OnTheLeft,Mode,Conjugate,TriStorageO } } } - - ei_aligned_stack_delete(Scalar, blockA, kc*mc); - ei_aligned_stack_delete(Scalar, allocatedBlockB, sizeB); } }; @@ -209,10 +206,10 @@ struct triangular_solve_matrix<Scalar,Index,OnTheRight,Mode,Conjugate,TriStorage Index nc = rows; // cache block size along the N direction computeProductBlockingSizes<Scalar,Scalar,4>(kc, mc, nc); - Scalar* blockA = ei_aligned_stack_new(Scalar, kc*mc); std::size_t sizeW = kc*Traits::WorkSpaceFactor; std::size_t sizeB = sizeW + kc*size; - Scalar* allocatedBlockB = ei_aligned_stack_new(Scalar, sizeB); + ei_declare_aligned_stack_constructed_variable(Scalar, blockA, kc*mc, 0); + ei_declare_aligned_stack_constructed_variable(Scalar, allocatedBlockB, sizeB, 0); Scalar* blockB = allocatedBlockB + sizeW; conj_if<Conjugate> conj; @@ -314,9 +311,6 @@ struct triangular_solve_matrix<Scalar,Index,OnTheRight,Mode,Conjugate,TriStorage -1, -1, 0, 0, allocatedBlockB); } } - - ei_aligned_stack_delete(Scalar, blockA, kc*mc); - ei_aligned_stack_delete(Scalar, allocatedBlockB, sizeB); } }; |