Commit 7d4de718 authored by Max Kellermann's avatar Max Kellermann

sticker/SongSticker: use AllocatedString for concatenation

parent e1c16d78
......@@ -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 <string.h>
#include <stdlib.h>
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment