diff options
author | David Robillard <d@drobilla.net> | 2019-03-07 22:41:35 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-03-08 09:07:18 +0100 |
commit | 8eba534e99cd8db29cca03035a115312935a22a3 (patch) | |
tree | cc13f89d5bdad33935fa4e8c396a740229be6b1e /tests | |
parent | acb958e95d0e8ca1b0dd912fe8bbf2e14e5f74e9 (diff) | |
download | ingen-8eba534e99cd8db29cca03035a115312935a22a3.tar.gz ingen-8eba534e99cd8db29cca03035a115312935a22a3.tar.bz2 ingen-8eba534e99cd8db29cca03035a115312935a22a3.zip |
Use smart pointers to handle FILE streams
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ingen_bench.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
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<FILE, decltype(&fclose)> 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<int32_t>(), (t_end - t_start) / 1000000.0, (n_test_frames / 48000.0)); - fclose(log); // Shut down world->engine()->deactivate(); |