From e425fe3f9725262ec4fc44ea0e5a12360c1a2479 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 31 Dec 2015 13:12:28 +0100 Subject: [PATCH] decoder/Thread: use std::unique_ptr --- src/decoder/DecoderThread.cxx | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/decoder/DecoderThread.cxx b/src/decoder/DecoderThread.cxx index 67e785d4e..668860fbf 100644 --- a/src/decoder/DecoderThread.cxx +++ b/src/decoder/DecoderThread.cxx @@ -307,21 +307,12 @@ TryDecoderFile(Decoder &decoder, Path path_fs, const char *suffix, const ScopeLock protect(dc.mutex); return decoder_file_decode(plugin, decoder, path_fs); } else if (plugin.stream_decode != nullptr) { - InputStream *input_stream = - decoder_input_stream_open(dc, path_fs); + std::unique_ptr input_stream(decoder_input_stream_open(dc, path_fs)); if (input_stream == nullptr) return false; - bool success; - { - const ScopeLock protect(dc.mutex); - success = decoder_stream_decode(plugin, decoder, - *input_stream); - } - - delete input_stream; - - return success; + const ScopeLock protect(dc.mutex); + return decoder_stream_decode(plugin, decoder, *input_stream); } else return false; }