]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Get rid of shared_ptr with weird deleter. Do it manually now.
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 17 Feb 2014 12:57:17 +0000 (12:57 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 17 Feb 2014 12:57:17 +0000 (12:57 +0000)
git-svn-id: https://svn.dealii.org/trunk@32498 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/matrix_free/fe_evaluation.h

index 5b7a3851090e9092ad2074a08a072f22a2df0746..92af89a2f7996b5083fef369aa61f234102dce47 100644 (file)
@@ -88,6 +88,11 @@ public:
    * @name 1: General operations
    */
   //@{
+  /**
+   * Destructor.
+   */
+  ~FEEvaluationBase();
+
   /**
    * Initializes the operation pointer to the current cell. Unlike the
    * FEValues::reinit function, where the information related to a particular
@@ -636,9 +641,10 @@ protected:
    * Stores a reference to the unit cell data, i.e., values, gradients and
    * Hessians in 1D at the quadrature points that constitute the tensor
    * product. Also contained in matrix_info, but it simplifies code if we
-   * store a reference to it.
+   * store a reference to it. If initialized without MatrixFree object, this
+   * call actually initializes the evaluation.
    */
-  std_cxx1x::shared_ptr<const internal::MatrixFreeFunctions::ShapeInfo<Number> > data;
+  const internal::MatrixFreeFunctions::ShapeInfo<Number> *data;
 
   /**
    * A pointer to the Cartesian Jacobian information of the present cell. Only
@@ -1666,34 +1672,6 @@ public:
 #ifndef DOXYGEN
 
 
-namespace internal
-{
-  namespace MatrixFreeFunctions
-  {
-    // a small class that gives control over the delete behavior of
-    // std::shared_ptr: we need to disable it when we initialize a pointer
-    // from another structure.
-    template <typename CLASS>
-    struct DummyDeleter
-    {
-      DummyDeleter (const bool do_delete = false)
-        :
-        do_delete(do_delete)
-      {}
-
-      void operator () (CLASS *pointer)
-      {
-        if (do_delete)
-          delete pointer;
-      }
-
-      const bool do_delete;
-    };
-  }
-}
-
-
-
 /*----------------------- FEEvaluationBase ----------------------------------*/
 
 template <int dim, int n_components_, typename Number>
@@ -1717,9 +1695,7 @@ FEEvaluationBase<dim,n_components_,Number>
   mapping_info       (&data_in.get_mapping_info()),
   data               (&data_in.get_shape_info
                       (fe_no_in, quad_no_in, active_fe_index,
-                       active_quad_index),
-                      internal::MatrixFreeFunctions::DummyDeleter
-                      <const internal::MatrixFreeFunctions::ShapeInfo<Number> >(false)),
+                       active_quad_index)),
   cartesian_data     (0),
   jacobian           (0),
   J_value            (0),
@@ -1808,6 +1784,18 @@ FEEvaluationBase<dim,n_components_,Number>
 
 
 
+template <int dim, int n_components_, typename Number>
+inline
+FEEvaluationBase<dim,n_components_,Number>::~FEEvaluationBase()
+{
+  // delete memory held by data in case this structure was initialized without
+  // a MatrixFree object which could hold the data structure.
+  if (matrix_info == 0)
+    delete data;
+}
+
+
+
 template <int dim, int n_components_, typename Number>
 inline
 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.