]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
another bug in SparsityPattern::block_read / block_write removed
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 1 Jul 2005 11:56:06 +0000 (11:56 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 1 Jul 2005 11:56:06 +0000 (11:56 +0000)
Functions are tested now

git-svn-id: https://svn.dealii.org/trunk@11031 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/source/sparsity_pattern.cc

index 842183200cfaca97a04efadd415331f345794ca8..191811128653d4045db28e213ea9201490c346c0 100644 (file)
@@ -882,7 +882,7 @@ SparsityPattern::block_write (std::ostream &out) const
       << diagonal_optimized << "][";
                                    // then write out real data
   out.write (reinterpret_cast<const char*>(&rowstart[0]),
-            reinterpret_cast<const char*>(&rowstart[max_dim])
+            reinterpret_cast<const char*>(&rowstart[max_dim+1])
             - reinterpret_cast<const char*>(&rowstart[0]));
   out << "][";
   out.write (reinterpret_cast<const char*>(&colnums[0]),
@@ -919,15 +919,17 @@ SparsityPattern::block_read (std::istream &in)
   AssertThrow (c == '[', ExcIO());
 
                                    // reallocate space
-  delete[] rowstart;
+  if (rowstart)
+    delete[] rowstart;
+  if (colnums)
   delete[] colnums;
 
-  rowstart = new unsigned int[max_dim];
+  rowstart = new unsigned int[max_dim+1];
   colnums  = new unsigned int[max_vec_len];
   
                                    // then read data
   in.read (reinterpret_cast<char*>(&rowstart[0]),
-           reinterpret_cast<char*>(&rowstart[max_dim])
+           reinterpret_cast<char*>(&rowstart[max_dim+1])
            - reinterpret_cast<char*>(&rowstart[0]));
   in >> c;
   AssertThrow (c == ']', ExcIO());

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.