From c17be5af6b5b6b841da8ba38729e2bd80a914fe3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 May 2016 18:46:06 +0200 Subject: [PATCH] test/run_encoder: use std::unique_ptr --- test/run_encoder.cxx | 9 ++++----- test/test_vorbis_encoder.cxx | 11 ++++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/run_encoder.cxx b/test/run_encoder.cxx index 234a86d3f..52857c2e8 100644 --- a/test/run_encoder.cxx +++ b/test/run_encoder.cxx @@ -29,6 +29,8 @@ #include "util/Error.hxx" #include "Log.hxx" +#include + #include #include #include @@ -65,7 +67,7 @@ int main(int argc, char **argv) try { Error error; - const auto p_encoder = encoder_init(*plugin, block, error); + std::unique_ptr p_encoder(encoder_init(*plugin, block, error)); if (p_encoder == nullptr) { LogError(error, "Failed to initialize encoder"); return EXIT_FAILURE; @@ -81,7 +83,7 @@ int main(int argc, char **argv) } } - auto *encoder = p_encoder->Open(audio_format, error); + std::unique_ptr encoder(p_encoder->Open(audio_format, error)); if (encoder == nullptr) { LogError(error, "Failed to open encoder"); return EXIT_FAILURE; @@ -110,9 +112,6 @@ int main(int argc, char **argv) EncoderToOutputStream(os, *encoder); - delete encoder; - delete p_encoder; - return EXIT_SUCCESS; } catch (const std::exception &e) { LogError(e); diff --git a/test/test_vorbis_encoder.cxx b/test/test_vorbis_encoder.cxx index fa13b2849..fb4a619dd 100644 --- a/test/test_vorbis_encoder.cxx +++ b/test/test_vorbis_encoder.cxx @@ -30,6 +30,8 @@ #include "util/Error.hxx" #include "Log.hxx" +#include + #include #include @@ -48,14 +50,16 @@ main(gcc_unused int argc, gcc_unused char **argv) ConfigBlock block; block.AddBlockParam("quality", "5.0", -1); - const auto p_encoder = encoder_init(*plugin, block, IgnoreError()); + std::unique_ptr p_encoder(encoder_init(*plugin, block, + IgnoreError())); assert(p_encoder != nullptr); try { /* open the encoder */ AudioFormat audio_format(44100, SampleFormat::S16, 2); - auto encoder = p_encoder->Open(audio_format, IgnoreError()); + std::unique_ptr encoder(p_encoder->Open(audio_format, + IgnoreError())); assert(encoder != nullptr); StdioOutputStream os(stdout); @@ -102,9 +106,6 @@ main(gcc_unused int argc, gcc_unused char **argv) EncoderToOutputStream(os, *encoder); - delete encoder; - delete p_encoder; - return EXIT_SUCCESS; } catch (const std::exception &e) { LogError(e);