From e1c16d78e40a1100d474f6dadba345181b98ef2e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 13 Oct 2021 12:08:47 +0200 Subject: [PATCH] decoder/wavpack: use AllocatedString for concatenation --- src/decoder/plugins/WavpackDecoderPlugin.cxx | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/decoder/plugins/WavpackDecoderPlugin.cxx b/src/decoder/plugins/WavpackDecoderPlugin.cxx index a2750c4cd..7054b557c 100644 --- a/src/decoder/plugins/WavpackDecoderPlugin.cxx +++ b/src/decoder/plugins/WavpackDecoderPlugin.cxx @@ -24,7 +24,7 @@ #include "pcm/CheckAudioFormat.hxx" #include "tag/Handler.hxx" #include "fs/Path.hxx" -#include "util/Alloc.hxx" +#include "util/AllocatedString.hxx" #include "util/Math.hxx" #include "util/ScopeExit.hxx" #include "util/RuntimeError.hxx" @@ -37,6 +37,8 @@ #include #include +using std::string_view_literals::operator""sv; + #define ERRORLEN 80 #ifdef OPEN_DSD_AS_PCM @@ -506,22 +508,12 @@ static WavpackStreamReader mpd_is_reader = { #endif static InputStreamPtr -wavpack_open_wvc(DecoderClient &client, const char *uri) +wavpack_open_wvc(DecoderClient &client, std::string_view uri) { - /* - * As we use dc->utf8url, this function will be bad for - * single files. utf8url is not absolute file path :/ - */ - if (uri == nullptr) - return nullptr; - - char *wvc_url = xstrcatdup(uri, "c"); - AtScopeExit(wvc_url) { - free(wvc_url); - }; + const AllocatedString wvc_url{uri, "c"sv}; try { - return client.OpenUri(wvc_url); + return client.OpenUri(wvc_url.c_str()); } catch (...) { return nullptr; }