From fc37c9860fd4fdcd29ee274b68bea2c933b0e27b Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@dune-project.org>
Date: Mon, 14 May 2012 16:10:14 +0000
Subject: [PATCH] Bugfix: During redistribution of the data objects were
 created with new and deallocated using the allocator. This works for the
 standard allocator but might break with others. This fix prevents this
 behaviour by using the allocator for the creation and allocation, too.
 Additionally, it prevents false positive during memory leak detection of
 valgrind.

Should fix flyspray #1047!


[[Imported from SVN: r1582]]
---
 dune/istl/paamg/hierarchy.hh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/dune/istl/paamg/hierarchy.hh b/dune/istl/paamg/hierarchy.hh
index 8e6a4410..dd9b972d 100644
--- a/dune/istl/paamg/hierarchy.hh
+++ b/dune/istl/paamg/hierarchy.hh
@@ -128,7 +128,7 @@ namespace Dune
        */
       void addCoarser(Arguments& args);
 
-      void addRedistributedOnCoarsest(T* t);
+      void addRedistributedOnCoarsest(Arguments& args);
 
       /**
        * @brief Add an element on a finer level.
@@ -1112,7 +1112,7 @@ namespace Dune
       Iterator matrix = matrices_.finest(), coarsest = matrices_.coarsest();
       int level=0;
       if(redist->isSetup())
-        hierarchy.addRedistributedOnCoarsest(new BlockVector<V,TA>(matrix.getRedistributed().getmat().N()));
+        hierarchy.addRedistributedOnCoarsest(matrix.getRedistributed().getmat().N());
       Dune::dvverb<<"Level "<<level<<" has "<<matrices_.finest()->getmat().N()<<" unknowns!"<<std::endl;
 
       while(matrix != coarsest) {
@@ -1121,7 +1121,7 @@ namespace Dune
 
         hierarchy.addCoarser(matrix->getmat().N());
         if(redist->isSetup())
-          hierarchy.addRedistributedOnCoarsest(new BlockVector<V,TA>(matrix.getRedistributed().getmat().N()));
+          hierarchy.addRedistributedOnCoarsest(matrix.getRedistributed().getmat().N());
 
       }
 
@@ -1260,9 +1260,9 @@ namespace Dune
     }
 
     template<class T, class A>
-    void Hierarchy<T,A>::addRedistributedOnCoarsest(T* t)
+    void Hierarchy<T,A>::addRedistributedOnCoarsest(Arguments& args)
     {
-      coarsest_->redistributed_ = t;
+      coarsest_->redistributed_ = ConstructionTraits<MemberType>::construct(args);
     }
 
     template<class T, class A>
-- 
GitLab