From f809b0ce42ba4f5f0db535092f4fe4330cdcbd6f Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 10 Nov 2016 23:01:26 -0700 Subject: [PATCH] Fix a memory leak in step-39. Also avoid some obscure old-style C functions. --- examples/step-39/step-39.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/step-39/step-39.cc b/examples/step-39/step-39.cc index aa55ccf0fa..b51ba0cad9 100644 --- a/examples/step-39/step-39.cc +++ b/examples/step-39/step-39.cc @@ -1,6 +1,6 @@ /* --------------------------------------------------------------------- * - * Copyright (C) 2010 - 2015 by the deal.II authors + * Copyright (C) 2010 - 2016 by the deal.II authors * * This file is part of the deal.II library. * @@ -859,16 +859,16 @@ namespace Step39 } - // Some graphical output + // Create graphical output. We produce the filename by collating the + // name from its various components, including the refinement cycle + // that we output with two digits. template void InteriorPenaltyProblem::output_results (const unsigned int cycle) const { - // Output of the solution in gnuplot format. - char *fn = new char[100]; - sprintf(fn, "sol-%02d", cycle); + const std::string filename = "sol-" + + Utilities::int_to_string(cycle,2) + + ".gnuplot"; - std::string filename(fn); - filename += ".gnuplot"; deallog << "Writing solution to <" << filename << ">..." << std::endl << std::endl; std::ofstream gnuplot_output (filename.c_str()); -- 2.39.5