sticker/SongSticker: use AllocatedString for concatenation
This commit is contained in:
parent
e1c16d78e4
commit
7d4de71899
@ -22,12 +22,13 @@
|
|||||||
#include "Database.hxx"
|
#include "Database.hxx"
|
||||||
#include "song/LightSong.hxx"
|
#include "song/LightSong.hxx"
|
||||||
#include "db/Interface.hxx"
|
#include "db/Interface.hxx"
|
||||||
#include "util/Alloc.hxx"
|
#include "util/AllocatedString.hxx"
|
||||||
#include "util/ScopeExit.hxx"
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
using std::string_view_literals::operator""sv;
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
sticker_song_get_value(StickerDatabase &db,
|
sticker_song_get_value(StickerDatabase &db,
|
||||||
const LightSong &song, const char *name)
|
const LightSong &song, const char *name)
|
||||||
@ -116,17 +117,15 @@ sticker_song_find(StickerDatabase &sticker_database, const Database &db,
|
|||||||
data.func = func;
|
data.func = func;
|
||||||
data.user_data = user_data;
|
data.user_data = user_data;
|
||||||
|
|
||||||
char *allocated;
|
AllocatedString allocated;
|
||||||
data.base_uri = base_uri;
|
data.base_uri = base_uri;
|
||||||
if (*data.base_uri != 0)
|
if (*data.base_uri != 0) {
|
||||||
/* append slash to base_uri */
|
/* append slash to base_uri */
|
||||||
data.base_uri = allocated =
|
allocated = AllocatedString{std::string_view{data.base_uri}, "/"sv};
|
||||||
xstrcatdup(data.base_uri, "/");
|
data.base_uri = allocated.c_str();
|
||||||
else
|
} else {
|
||||||
/* searching in root directory - no trailing slash */
|
/* searching in root directory - no trailing slash */
|
||||||
allocated = nullptr;
|
}
|
||||||
|
|
||||||
AtScopeExit(allocated) { free(allocated); };
|
|
||||||
|
|
||||||
data.base_uri_length = strlen(data.base_uri);
|
data.base_uri_length = strlen(data.base_uri);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user