decoder/mikmod: use const_cast instead of g_strdup()
This commit is contained in:
parent
0a213ddf03
commit
39e2ffe212
@ -148,14 +148,15 @@ mikmod_decoder_finish(void)
|
|||||||
static void
|
static void
|
||||||
mikmod_decoder_file_decode(struct decoder *decoder, const char *path_fs)
|
mikmod_decoder_file_decode(struct decoder *decoder, const char *path_fs)
|
||||||
{
|
{
|
||||||
char *path2;
|
/* deconstify the path because libmikmod wants a non-const
|
||||||
|
string pointer */
|
||||||
|
char *const path2 = const_cast<char *>(path_fs);
|
||||||
|
|
||||||
MODULE *handle;
|
MODULE *handle;
|
||||||
int ret;
|
int ret;
|
||||||
SBYTE buffer[MIKMOD_FRAME_SIZE];
|
SBYTE buffer[MIKMOD_FRAME_SIZE];
|
||||||
|
|
||||||
path2 = g_strdup(path_fs);
|
|
||||||
handle = Player_Load(path2, 128, 0);
|
handle = Player_Load(path2, 128, 0);
|
||||||
g_free(path2);
|
|
||||||
|
|
||||||
if (handle == nullptr) {
|
if (handle == nullptr) {
|
||||||
FormatError(mikmod_domain,
|
FormatError(mikmod_domain,
|
||||||
@ -186,22 +187,21 @@ static bool
|
|||||||
mikmod_decoder_scan_file(const char *path_fs,
|
mikmod_decoder_scan_file(const char *path_fs,
|
||||||
const struct tag_handler *handler, void *handler_ctx)
|
const struct tag_handler *handler, void *handler_ctx)
|
||||||
{
|
{
|
||||||
char *path2 = g_strdup(path_fs);
|
/* deconstify the path because libmikmod wants a non-const
|
||||||
|
string pointer */
|
||||||
|
char *const path2 = const_cast<char *>(path_fs);
|
||||||
|
|
||||||
MODULE *handle = Player_Load(path2, 128, 0);
|
MODULE *handle = Player_Load(path2, 128, 0);
|
||||||
|
|
||||||
if (handle == nullptr) {
|
if (handle == nullptr) {
|
||||||
g_free(path2);
|
|
||||||
FormatDebug(mikmod_domain,
|
FormatDebug(mikmod_domain,
|
||||||
"Failed to open file: %s", path_fs);
|
"Failed to open file: %s", path_fs);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player_Free(handle);
|
Player_Free(handle);
|
||||||
|
|
||||||
char *title = Player_LoadTitle(path2);
|
char *title = Player_LoadTitle(path2);
|
||||||
g_free(path2);
|
|
||||||
|
|
||||||
if (title != nullptr) {
|
if (title != nullptr) {
|
||||||
tag_handler_invoke_tag(handler, handler_ctx,
|
tag_handler_invoke_tag(handler, handler_ctx,
|
||||||
TAG_TITLE, title);
|
TAG_TITLE, title);
|
||||||
|
Loading…
Reference in New Issue
Block a user