diff --git a/osdep/win32/smtc.cpp b/osdep/win32/smtc.cpp index 904d60539f..4e5365e46b 100644 --- a/osdep/win32/smtc.cpp +++ b/osdep/win32/smtc.cpp @@ -53,7 +53,6 @@ struct mpv_deleter { } }; using mp_string = std::unique_ptr; -using talloc_ctx = std::unique_ptr; struct mp_node : mpv_node { mp_node() = default; @@ -208,8 +207,7 @@ static void update_thumbnail(SystemMediaTransportControls &smtc, smtc_ctx &ctx) try { if (thumbnail) { - talloc_ctx ta_ctx{ talloc_new(nullptr) }; - mp_string normalized_path{ mp_normalize_path(ta_ctx.get(), thumbnail) }; + mp_string normalized_path{ mp_normalize_path(nullptr, thumbnail) }; MP_TRACE(&ctx, "Using thumbnail: %s\n", normalized_path.get()); auto hstr = winrt::to_hstring(normalized_path.get()); RandomAccessStreamReference stream_ref{ nullptr }; @@ -225,8 +223,7 @@ static void update_thumbnail(SystemMediaTransportControls &smtc, smtc_ctx &ctx) updater.Thumbnail(stream_ref); } else { if (filepath && !mp_is_url(bstr0(filepath.get()))) { - talloc_ctx ta_ctx{ talloc_new(nullptr) }; - mp_string path{ mp_normalize_path(ta_ctx.get(), filepath.get()) }; + mp_string path{ mp_normalize_path(nullptr, filepath.get()) }; MP_TRACE(&ctx, "Generating thumbnail for: %s\n", path.get()); auto storage_file = StorageFile::GetFileFromPathAsync(winrt::to_hstring(path.get())); diff --git a/player/command.c b/player/command.c index 318e382deb..e3ba26f5fd 100644 --- a/player/command.c +++ b/player/command.c @@ -5924,15 +5924,14 @@ static void cmd_normalize_path(void *p) { struct mp_cmd_ctx *cmd = p; struct MPContext *mpctx = cmd->mpctx; - void *ctx = talloc_new(NULL); - char *path = mp_get_user_path(ctx, mpctx->global, cmd->args[0].v.s); + char *path = mp_get_user_path(NULL, mpctx->global, cmd->args[0].v.s); cmd->result = (mpv_node){ .format = MPV_FORMAT_STRING, - .u.string = talloc_steal(NULL, mp_normalize_path(ctx, path)), + .u.string = mp_normalize_path(NULL, path), }; - talloc_free(ctx); + talloc_free(path); } static void cmd_escape_ass(void *p) diff --git a/player/configfiles.c b/player/configfiles.c index ceb405c0cd..418937b11d 100644 --- a/player/configfiles.c +++ b/player/configfiles.c @@ -396,8 +396,7 @@ exit: void mp_delete_watch_later_conf(struct MPContext *mpctx, const char *file) { - void *ctx = talloc_new(NULL); - char *path = mp_normalize_path(ctx, file ? file : mpctx->filename); + char *path = mp_normalize_path(NULL, file ? file : mpctx->filename); if (!path) goto exit; @@ -424,7 +423,7 @@ void mp_delete_watch_later_conf(struct MPContext *mpctx, const char *file) } exit: - talloc_free(ctx); + talloc_free(path); } bool mp_load_playback_resume(struct MPContext *mpctx, const char *file) diff --git a/test/paths.c b/test/paths.c index d0f020a0f6..1d0d06badd 100644 --- a/test/paths.c +++ b/test/paths.c @@ -14,10 +14,9 @@ static void test_join(char *file, int line, char *a, char *b, char *c) static void test_normalize(char *file, int line, char *expected, char *path) { - void *ctx = talloc_new(NULL); - char *normalized = mp_normalize_path(ctx, path); + char *normalized = mp_normalize_path(NULL, path); assert_string_equal_impl(file, line, normalized, expected); - talloc_free(ctx); + talloc_free(normalized); } static void test_dirname(char *file, int line, char *path, char *expected)