From: Wolfgang Bangerth Date: Fri, 11 Nov 2016 06:01:26 +0000 (-0700) Subject: Fix a memory leak in step-39. X-Git-Tag: v8.5.0-rc1~413^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f809b0ce42ba4f5f0db535092f4fe4330cdcbd6f;p=dealii.git Fix a memory leak in step-39. Also avoid some obscure old-style C functions. --- 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());