From 12b7ff65b949040f546260f7e6946c742e8bd626 Mon Sep 17 00:00:00 2001
From: Wolfgang Bangerth <bangerth@colostate.edu>
Date: Thu, 10 Nov 2016 09:29:49 -0700
Subject: [PATCH] Fix a variety of memory leaks in the testsuite.

---
 tests/bits/step-14.cc                              | 14 ++++++++------
 tests/lac/constraints_block_01.cc                  |  6 +++---
 tests/multigrid/step-39-03.cc                      |  2 ++
 .../parameter_handler_double_02.cc                 |  3 ++-
 4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/tests/bits/step-14.cc b/tests/bits/step-14.cc
index c24272fc0f..ba43cc5637 100644
--- a/tests/bits/step-14.cc
+++ b/tests/bits/step-14.cc
@@ -1,6 +1,6 @@
 // ---------------------------------------------------------------------
 //
-// Copyright (C) 2005 - 2015 by the deal.II authors
+// Copyright (C) 2005 - 2016 by the deal.II authors
 //
 // This file is part of the deal.II library.
 //
@@ -2124,6 +2124,11 @@ int main ()
       deallog.threshold_double(1.e-10);
 
       const unsigned int dim = 2;
+
+      Data::SetUp<Data::Exercise_2_3<dim>,dim> setup;
+      const Point<dim> evaluation_point (0.75, 0.75);
+      DualFunctional::PointValueEvaluation<dim> eval(evaluation_point);
+
       Framework<dim>::ProblemDescription descriptor;
 
       descriptor.refinement_criterion
@@ -2132,11 +2137,8 @@ int main ()
       descriptor.primal_fe_degree = 1;
       descriptor.dual_fe_degree   = 2;
 
-      descriptor.data = new Data::SetUp<Data::Exercise_2_3<dim>,dim> ();
-
-      const Point<dim> evaluation_point (0.75, 0.75);
-      descriptor.dual_functional
-        = new DualFunctional::PointValueEvaluation<dim> (evaluation_point);
+      descriptor.data = &setup;
+      descriptor.dual_functional = &eval;
 
       Evaluation::PointValueEvaluation<dim>
       postprocessor1 (evaluation_point);
diff --git a/tests/lac/constraints_block_01.cc b/tests/lac/constraints_block_01.cc
index 788eba7849..2d3891b39e 100644
--- a/tests/lac/constraints_block_01.cc
+++ b/tests/lac/constraints_block_01.cc
@@ -1,6 +1,6 @@
 // ---------------------------------------------------------------------
 //
-// Copyright (C) 2012 - 2015 by the deal.II authors
+// Copyright (C) 2012 - 2016 by the deal.II authors
 //
 // This file is part of the deal.II library.
 //
@@ -114,8 +114,8 @@ int main ()
   std::string fluid_fe_name = "FESystem[FE_Nothing()^2-FE_Nothing()^2-FE_Q(2)^2-FE_Q(1)-FE_Q(2)^2]";
 
   hp::FECollection<dim> fe_collection;
-  FiniteElement<dim> *solid_fe = FETools::get_fe_by_name<dim, dim>(solid_fe_name);
-  FiniteElement<dim> *fluid_fe = FETools::get_fe_by_name<dim, dim>(fluid_fe_name);
+  std_cxx11::unique_ptr<FiniteElement<dim> > solid_fe (FETools::get_fe_by_name<dim, dim>(solid_fe_name));
+  std_cxx11::unique_ptr<FiniteElement<dim> > fluid_fe (FETools::get_fe_by_name<dim, dim>(fluid_fe_name));
 
   deallog << "Solid FE Space: " << solid_fe->get_name() << std::endl;
   deallog << "Fluid/Mesh FE Space: " << fluid_fe->get_name() << std::endl;
diff --git a/tests/multigrid/step-39-03.cc b/tests/multigrid/step-39-03.cc
index f082fb49df..64428156b4 100644
--- a/tests/multigrid/step-39-03.cc
+++ b/tests/multigrid/step-39-03.cc
@@ -675,6 +675,8 @@ namespace Step39
     data_out.build_patches ();
 
     data_out.write_gnuplot(gnuplot_output);
+
+    delete[] fn;
   }
 
   template <int dim>
diff --git a/tests/parameter_handler/parameter_handler_double_02.cc b/tests/parameter_handler/parameter_handler_double_02.cc
index a42fedba5b..1b60e2b141 100644
--- a/tests/parameter_handler/parameter_handler_double_02.cc
+++ b/tests/parameter_handler/parameter_handler_double_02.cc
@@ -1,6 +1,6 @@
 // ---------------------------------------------------------------------
 //
-// Copyright (C) 2003 - 2015 by the deal.II authors
+// Copyright (C) 2003 - 2016 by the deal.II authors
 //
 // This file is part of the deal.II library.
 //
@@ -33,6 +33,7 @@ void test(const std::string &desc)
       return;
     }
   deallog << c->description() << std::endl;
+  delete c;
 }
 
 
-- 
2.39.5