diff options
author | Max Kellermann <max@duempel.org> | 2013-10-19 17:30:56 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-10-19 17:30:56 +0200 |
commit | 39e2ffe212acdbb240867606f31b16c5f8f3fdfc (patch) | |
tree | e6f404dc13ccd2ee44a33dca509c68c11172a90f /src/decoder/MikmodDecoderPlugin.cxx | |
parent | 0a213ddf037434ec9f2cd1759e3eb747d1972445 (diff) | |
download | mpd-39e2ffe212acdbb240867606f31b16c5f8f3fdfc.tar.gz mpd-39e2ffe212acdbb240867606f31b16c5f8f3fdfc.tar.xz mpd-39e2ffe212acdbb240867606f31b16c5f8f3fdfc.zip |
decoder/mikmod: use const_cast instead of g_strdup()
Diffstat (limited to '')
-rw-r--r-- | src/decoder/MikmodDecoderPlugin.cxx | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/decoder/MikmodDecoderPlugin.cxx b/src/decoder/MikmodDecoderPlugin.cxx index 6f2fd039d..2b0978d45 100644 --- a/src/decoder/MikmodDecoderPlugin.cxx +++ b/src/decoder/MikmodDecoderPlugin.cxx @@ -148,14 +148,15 @@ mikmod_decoder_finish(void) static void 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; int ret; SBYTE buffer[MIKMOD_FRAME_SIZE]; - path2 = g_strdup(path_fs); handle = Player_Load(path2, 128, 0); - g_free(path2); if (handle == nullptr) { FormatError(mikmod_domain, @@ -186,22 +187,21 @@ static bool mikmod_decoder_scan_file(const char *path_fs, 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); if (handle == nullptr) { - g_free(path2); FormatDebug(mikmod_domain, "Failed to open file: %s", path_fs); return false; - } Player_Free(handle); char *title = Player_LoadTitle(path2); - g_free(path2); - if (title != nullptr) { tag_handler_invoke_tag(handler, handler_ctx, TAG_TITLE, title); |