From 8eba534e99cd8db29cca03035a115312935a22a3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 7 Mar 2019 22:41:35 +0100 Subject: Use smart pointers to handle FILE streams --- tests/ingen_bench.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/ingen_bench.cpp b/tests/ingen_bench.cpp index c51b4d79..b51ec364 100644 --- a/tests/ingen_bench.cpp +++ b/tests/ingen_bench.cpp @@ -122,15 +122,15 @@ main(int argc, char** argv) const uint64_t t_end = clock.now_microseconds(); // Write log output - FILE* log = fopen(out_file.c_str(), "a"); - if (ftell(log) == 0) { - fprintf(log, "# n_threads\trun_time\treal_time\n"); + std::unique_ptr log{fopen(out_file.c_str(), "a"), + &fclose}; + if (ftell(log.get()) == 0) { + fprintf(log.get(), "# n_threads\trun_time\treal_time\n"); } - fprintf(log, "%u\t%f\t%f\n", + fprintf(log.get(), "%u\t%f\t%f\n", world->conf().option("threads").get(), (t_end - t_start) / 1000000.0, (n_test_frames / 48000.0)); - fclose(log); // Shut down world->engine()->deactivate(); -- cgit v1.2.1