diff --git a/src/sticker/SongSticker.cxx b/src/sticker/SongSticker.cxx index 4f6dedffe..9becc2e22 100644 --- a/src/sticker/SongSticker.cxx +++ b/src/sticker/SongSticker.cxx @@ -22,12 +22,13 @@ #include "Database.hxx" #include "song/LightSong.hxx" #include "db/Interface.hxx" -#include "util/Alloc.hxx" -#include "util/ScopeExit.hxx" +#include "util/AllocatedString.hxx" #include #include +using std::string_view_literals::operator""sv; + std::string sticker_song_get_value(StickerDatabase &db, const LightSong &song, const char *name) @@ -116,17 +117,15 @@ sticker_song_find(StickerDatabase &sticker_database, const Database &db, data.func = func; data.user_data = user_data; - char *allocated; + AllocatedString allocated; data.base_uri = base_uri; - if (*data.base_uri != 0) + if (*data.base_uri != 0) { /* append slash to base_uri */ - data.base_uri = allocated = - xstrcatdup(data.base_uri, "/"); - else + allocated = AllocatedString{std::string_view{data.base_uri}, "/"sv}; + data.base_uri = allocated.c_str(); + } else { /* searching in root directory - no trailing slash */ - allocated = nullptr; - - AtScopeExit(allocated) { free(allocated); }; + } data.base_uri_length = strlen(data.base_uri);