]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix a memory leak in the block matrix.
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 4 Nov 2008 13:37:21 +0000 (13:37 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 4 Nov 2008 13:37:21 +0000 (13:37 +0000)
git-svn-id: https://svn.dealii.org/trunk@17467 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/source/trilinos_block_sparse_matrix.cc

index 6c8272208634c608c15fbf12d366f84d2def4b24..ecb2efeac3cac391172496fde422fa5a2e74bcec 100644 (file)
@@ -27,7 +27,18 @@ namespace TrilinosWrappers
 
 
   BlockSparseMatrix::~BlockSparseMatrix ()
-  {}
+  {
+                                  // delete previous content of
+                                  // the subobjects array
+    for (unsigned int r=0; r<this->n_block_rows(); ++r)
+      for (unsigned int c=0; c<this->n_block_cols(); ++c)
+       {
+         BlockType *p = this->sub_objects[r][c];
+         this->sub_objects[r][c] = 0;
+         delete p;
+       }
+
+  }
 
 
 
@@ -104,17 +115,14 @@ namespace TrilinosWrappers
     
     const unsigned int n_block_rows = input_maps.size();
 
-    if (input_maps[0].Comm().MyPID()==0)
-      {
-       Assert (n_block_rows == block_sparsity_pattern.n_block_rows(),
-               ExcDimensionMismatch (n_block_rows,
-                                     block_sparsity_pattern.n_block_rows()));
-       Assert (n_block_rows == block_sparsity_pattern.n_block_cols(),
-               ExcDimensionMismatch (n_block_rows,
-                                     block_sparsity_pattern.n_block_cols()));
-      }
+    Assert (n_block_rows == block_sparsity_pattern.n_block_rows(),
+           ExcDimensionMismatch (n_block_rows,
+                                 block_sparsity_pattern.n_block_rows()));
+    Assert (n_block_rows == block_sparsity_pattern.n_block_cols(),
+           ExcDimensionMismatch (n_block_rows,
+                                 block_sparsity_pattern.n_block_cols()));
 
-                                    // Call the other basic reinit function ...
+                                    // Call the other basic reinit function...
     reinit (n_block_rows, n_block_rows);
        
                                     // ... and then assign the correct

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.