]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Perform more bounds checking in dSMatrixStruct
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 18 Mar 1998 14:48:11 +0000 (14:48 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 18 Mar 1998 14:48:11 +0000 (14:48 +0000)
git-svn-id: https://svn.dealii.org/trunk@77 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/dsmatrix.h
deal.II/lac/source/dsmatrix.cc

index 621f13044b77153a95b33bad9f698574eb3b0204..46b188952eceec49c15f7546ca52aff3d81e51e1 100644 (file)
@@ -96,7 +96,13 @@ public:
                    int, int,
                    << "The given index " << arg1
                    << " should be less than " << arg2 << ".");
-
+                                    /**
+                                     * Exception
+                                     */
+    DeclException1 (ExcNotEnoughSpace,
+                   int,
+                   << "Upon entering a new entry to row " << arg1
+                   << ": there was no free entry any more.");
 };
 
 
index 38b51072012bfa7595b127e7c70f045fffa740f7..d70f3826b38ab0b9b38fa09a03fdc1dbff673b4c 100644 (file)
@@ -205,16 +205,23 @@ dSMatrixStruct::add (int i, int j)
   Assert ((i>=0) && (i<rows), ExcInvalidIndex(i,rows));
   Assert ((j>=0) && (j<cols), ExcInvalidIndex(j,cols));
 
-  int k;
-  for (k=rowstart[i]; k<rowstart[i+1]; k++)
+  for (int k=rowstart[i]; k<rowstart[i+1]; k++)
     {
+                                      // entry already exists
       if (colnums[k] == j) return;
+                                      // empty entry found, put new
+                                      // entry here
       if (colnums[k] == -1)
        {
          colnums[k] = j;
          return;
-       }
-    }
+       };
+    };
+
+                                  // if we came thus far, something went
+                                  // wrong: there was not enough space
+                                  // in this line
+  Assert (false, ExcNotEnoughSpace(i));
 }
 
 void

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.