]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Initialize a local variable and general cleanup.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 10 Mar 2010 00:46:59 +0000 (00:46 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 10 Mar 2010 00:46:59 +0000 (00:46 +0000)
git-svn-id: https://svn.dealii.org/trunk@20779 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/constraint_matrix.templates.h

index 37aa2128da7e5134d930871d0b3db46cb303cd58..6df7772742abddfbd4f808b836ddbd020fbb62de 100644 (file)
@@ -1010,62 +1010,88 @@ namespace internals
                                    // is much more expensive
   struct DataCache
   {
-    DataCache () : element_size (0), data (0) {};
-    ~DataCache() { if (data != 0) {delete [] data;} };
-    void reinit () { Assert (element_size == 0, ExcInternalError());
-      element_size = 6; data = new std::pair<unsigned int,double> [20*6];
-      individual_size.resize(20), n_used_elements = 0;};
-    unsigned int element_size;
-    std::pair<unsigned int,double> * data;
-    std::vector<unsigned int> individual_size;
-    unsigned int n_used_elements;
-
-    unsigned int insert_new_index (const std::pair<unsigned int,double> &pair)
-    {
-      if (element_size == 0)
-       reinit();
-      if (n_used_elements == individual_size.size())
+      DataCache ()
+                     :
+                     element_size (0),
+                     data (0),
+                     n_used_elements(0)
+       {}
+
+      ~DataCache()
        {
-         std::pair<unsigned int,double> * new_data =
-           new std::pair<unsigned int,double> [2*individual_size.size()*element_size];
-         memcpy (new_data, data, individual_size.size()*element_size*
-                 sizeof(std::pair<unsigned int,double>));
-         delete [] data;
-         data = new_data;
-         individual_size.resize (2*individual_size.size(), 0);
+         if (data != 0)
+           delete [] data;
        }
-      unsigned int index = n_used_elements;
-      data[index*element_size] = pair;
-      individual_size[index] = 1;
-      ++n_used_elements;
-      return index;
-    }
 
-    void append_index (const unsigned int index,
-                      const std::pair<unsigned int,double> &pair)
-    {
-      Assert (index < n_used_elements, ExcIndexRange (index, 0, n_used_elements));
-      const unsigned int my_size = individual_size[index];
-      if (my_size == element_size)
+      void reinit ()
        {
-         std::pair<unsigned int,double> * new_data =
-           new std::pair<unsigned int,double> [2*individual_size.size()*element_size];
-         for (unsigned int i=0; i<n_used_elements; ++i)
-           memcpy (&new_data[i*element_size*2], &data[i*element_size],
-                   element_size*sizeof(std::pair<unsigned int,double>));
-         delete [] data;
-         data = new_data;
-         element_size *= 2;
+         Assert (element_size == 0, ExcInternalError());
+         element_size = 6;
+         data = new std::pair<unsigned int,double> [20*6];
+         individual_size.resize(20);
+         n_used_elements = 0;
        }
-      data[index*element_size+my_size] = pair;
-      individual_size[index]++;
-    };
 
-    unsigned int
-    get_size (const unsigned int index) const { return individual_size[index]; };
+      unsigned int element_size;
+
+      std::pair<unsigned int,double> * data;
+
+      std::vector<unsigned int> individual_size;
+
+      unsigned int n_used_elements;
+
+      unsigned int insert_new_index (const std::pair<unsigned int,double> &pair)
+       {
+         if (element_size == 0)
+           reinit();
+         if (n_used_elements == individual_size.size())
+           {
+             std::pair<unsigned int,double> * new_data =
+               new std::pair<unsigned int,double> [2*individual_size.size()*element_size];
+             memcpy (new_data, data, individual_size.size()*element_size*
+                     sizeof(std::pair<unsigned int,double>));
+             delete [] data;
+             data = new_data;
+             individual_size.resize (2*individual_size.size(), 0);
+           }
+         unsigned int index = n_used_elements;
+         data[index*element_size] = pair;
+         individual_size[index] = 1;
+         ++n_used_elements;
+         return index;
+       }
 
-    const std::pair<unsigned int,double> *
-    get_entry (const unsigned int index) const { return &data[index*element_size]; };
+      void append_index (const unsigned int index,
+                        const std::pair<unsigned int,double> &pair)
+       {
+         Assert (index < n_used_elements, ExcIndexRange (index, 0, n_used_elements));
+         const unsigned int my_size = individual_size[index];
+         if (my_size == element_size)
+           {
+             std::pair<unsigned int,double> * new_data =
+               new std::pair<unsigned int,double> [2*individual_size.size()*element_size];
+             for (unsigned int i=0; i<n_used_elements; ++i)
+               memcpy (&new_data[i*element_size*2], &data[i*element_size],
+                       element_size*sizeof(std::pair<unsigned int,double>));
+             delete [] data;
+             data = new_data;
+             element_size *= 2;
+           }
+         data[index*element_size+my_size] = pair;
+         individual_size[index]++;
+       }
+
+      unsigned int
+      get_size (const unsigned int index) const
+       {
+         return individual_size[index];
+       }
+
+      const std::pair<unsigned int,double> *
+      get_entry (const unsigned int index) const
+       {
+         return &data[index*element_size];
+       }
   };
 
 

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.