diff --git a/demux/cache.c b/demux/cache.c index 11e8e7ef5a..6882132fa8 100644 --- a/demux/cache.c +++ b/demux/cache.c @@ -105,7 +105,7 @@ struct demux_cache *demux_cache_create(struct mpv_global *global, char *cache_dir = cache->opts->cache_dir; if (cache_dir && cache_dir[0]) { - cache_dir = mp_get_user_path(NULL, global, cache_dir); + cache_dir = talloc_strdup(NULL, cache_dir); } else { cache_dir = mp_find_user_file(NULL, global, "cache", ""); } @@ -116,6 +116,7 @@ struct demux_cache *demux_cache_create(struct mpv_global *global, mp_mkdirp(cache_dir); cache->filename = mp_path_join(cache, cache_dir, "mpv-cache-XXXXXX.dat"); cache->fd = mp_mkostemps(cache->filename, 4, O_CLOEXEC); + talloc_free(cache_dir); if (cache->fd < 0) { MP_ERR(cache, "Failed to create cache temporary file.\n"); goto fail; diff --git a/input/input.c b/input/input.c index 412c6db319..89ddf5f407 100644 --- a/input/input.c +++ b/input/input.c @@ -1649,8 +1649,6 @@ static bool parse_config_file(struct input_ctx *ictx, char *file) bool r = false; void *tmp = talloc_new(NULL); - file = mp_get_user_path(tmp, ictx->global, file); - bstr data = stream_read_file2(file, tmp, STREAM_ORIGIN_DIRECT | STREAM_READ, ictx->global, 1000000); if (data.start) { diff --git a/input/ipc-unix.c b/input/ipc-unix.c index 3eab683506..6e89c77c68 100644 --- a/input/ipc-unix.c +++ b/input/ipc-unix.c @@ -389,7 +389,7 @@ struct mp_ipc_ctx *mp_init_ipc(struct mp_client_api *client_api, *arg = (struct mp_ipc_ctx){ .log = mp_log_new(arg, global->log, "ipc"), .client_api = client_api, - .path = mp_get_user_path(arg, global, opts->ipc_path), + .path = talloc_strdup(arg, opts->ipc_path), .death_pipe = {-1, -1}, }; diff --git a/player/command.c b/player/command.c index 999e74d4d7..f03bc3f47a 100644 --- a/player/command.c +++ b/player/command.c @@ -6950,8 +6950,9 @@ static void cmd_load_input_conf(void *p) struct mp_cmd_ctx *cmd = p; struct MPContext *mpctx = cmd->mpctx; - char *config_file = cmd->args[0].v.s; + char *config_file = mp_get_user_path(NULL, mpctx->global, cmd->args[0].v.s); cmd->success = mp_input_load_config_file(mpctx->input, config_file); + talloc_free(config_file); } static void cmd_load_script(void *p) diff --git a/player/configfiles.c b/player/configfiles.c index 4c44feab8a..01a3432424 100644 --- a/player/configfiles.c +++ b/player/configfiles.c @@ -201,7 +201,7 @@ char *mp_get_playback_resume_dir(struct MPContext *mpctx) { char *wl_dir = mpctx->opts->watch_later_dir; if (wl_dir && wl_dir[0]) { - wl_dir = mp_get_user_path(mpctx, mpctx->global, wl_dir); + wl_dir = talloc_strdup(mpctx, wl_dir); } else { wl_dir = mp_find_user_file(mpctx, mpctx->global, "state", MP_WATCH_LATER_CONF); } diff --git a/player/loadfile.c b/player/loadfile.c index 748b3f5731..188527a49c 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -1545,8 +1545,7 @@ static void append_to_watch_history(struct MPContext *mpctx) return; void *ctx = talloc_new(NULL); - char *history_path = mp_get_user_path(ctx, mpctx->global, - mpctx->opts->watch_history_path); + char *history_path = mpctx->opts->watch_history_path; char *history_path_dir = bstrto0(ctx, mp_dirname(history_path)); mp_mkdirp(history_path_dir); diff --git a/player/screenshot.c b/player/screenshot.c index cc47d6a9e2..38660268eb 100644 --- a/player/screenshot.c +++ b/player/screenshot.c @@ -297,7 +297,6 @@ static char *gen_fname(struct mp_cmd_ctx *cmd, const char *file_ext) char *dir = ctx->mpctx->opts->screenshot_dir; if (dir && dir[0]) { void *t = fname; - dir = mp_get_user_path(t, ctx->mpctx->global, dir); fname = mp_path_join(NULL, dir, fname); mp_mkdirp(dir); diff --git a/player/scripting.c b/player/scripting.c index 231ed8f10a..3c68547e78 100644 --- a/player/scripting.c +++ b/player/scripting.c @@ -280,7 +280,7 @@ bool mp_load_scripts(struct MPContext *mpctx) char **files = mpctx->opts->script_files; for (int n = 0; files && files[n]; n++) { if (files[n][0]) - ok &= mp_load_user_script(mpctx, files[n]) >= 0; + ok &= mp_load_script(mpctx, files[n]) >= 0; } if (!mpctx->opts->auto_load_scripts) return ok; diff --git a/sub/ass_mp.c b/sub/ass_mp.c index 4cbebc872a..2991bf0a20 100644 --- a/sub/ass_mp.c +++ b/sub/ass_mp.c @@ -131,7 +131,7 @@ ASS_Library *mp_ass_init(struct mpv_global *global, struct osd_style_opts *opts, struct mp_log *log) { char *path = opts->fonts_dir && opts->fonts_dir[0] ? - mp_get_user_path(NULL, global, opts->fonts_dir) : + talloc_strdup(NULL, opts->fonts_dir) : mp_find_config_file(NULL, global, "fonts"); mp_dbg(log, "ASS library version: 0x%x (runtime 0x%x)\n", (unsigned)LIBASS_VERSION, ass_library_version()); diff --git a/video/filter/vf_vapoursynth.c b/video/filter/vf_vapoursynth.c index d2ab916220..5ad6ff9cea 100644 --- a/video/filter/vf_vapoursynth.c +++ b/video/filter/vf_vapoursynth.c @@ -750,7 +750,7 @@ static struct mp_filter *vf_vapoursynth_create(struct mp_filter *parent, MP_FATAL(p, "'file' parameter must be set.\n"); goto error; } - p->script_path = mp_get_user_path(p, f->global, p->opts->file); + p->script_path = talloc_strdup(p, p->opts->file); p->max_requests = p->opts->maxrequests; if (p->max_requests < 0) diff --git a/video/out/gpu/lcms.c b/video/out/gpu/lcms.c index c197acf48e..05a08921de 100644 --- a/video/out/gpu/lcms.c +++ b/video/out/gpu/lcms.c @@ -73,11 +73,10 @@ static void load_profile(struct gl_lcms *p) if (!p->opts->profile || !p->opts->profile[0]) return; - char *fname = mp_get_user_path(NULL, p->global, p->opts->profile); + char *fname = p->opts->profile; MP_VERBOSE(p, "Opening ICC profile '%s'\n", fname); struct bstr iccdata = stream_read_file(fname, p, p->global, 100000000); // 100 MB - talloc_free(fname); if (!iccdata.len) return; @@ -365,7 +364,7 @@ bool gl_lcms_get_lut3d(struct gl_lcms *p, struct lut3d **result_lut3d, char *cache_dir = p->opts->cache_dir; if (cache_dir && cache_dir[0]) { - cache_dir = mp_get_user_path(tmp, p->global, cache_dir); + cache_dir = talloc_strdup(tmp, cache_dir); } else { cache_dir = mp_find_user_file(tmp, p->global, "cache", ""); } diff --git a/video/out/gpu/shader_cache.c b/video/out/gpu/shader_cache.c index 889e5e85d3..1a9ad6cc85 100644 --- a/video/out/gpu/shader_cache.c +++ b/video/out/gpu/shader_cache.c @@ -559,7 +559,7 @@ void gl_sc_set_cache_dir(struct gl_shader_cache *sc, char *dir) { talloc_free(sc->cache_dir); if (dir && dir[0]) { - dir = mp_get_user_path(NULL, sc->global, dir); + dir = talloc_strdup(NULL, dir); } else { dir = mp_find_user_file(NULL, sc->global, "cache", ""); } diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index b994d186cb..8ef180a335 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -583,9 +583,7 @@ static struct bstr load_cached_file(struct gl_video *p, const char *path) return p->files[n].body; } // not found -> load it - char *fname = mp_get_user_path(NULL, p->global, path); - struct bstr s = stream_read_file(fname, p, p->global, 1000000000); // 1GB - talloc_free(fname); + struct bstr s = stream_read_file(path, p, p->global, 1000000000); // 1GB if (s.len) { struct cached_file new = { .path = talloc_strdup(p, path), diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index f8d1189b62..be67e1ca05 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -1809,7 +1809,7 @@ static void cache_init(struct vo *vo, struct cache *cache, size_t max_size, char *dir; if (dir_opt && dir_opt[0]) { - dir = mp_get_user_path(vo, p->global, dir_opt); + dir = talloc_strdup(vo, dir_opt); } else { dir = mp_find_user_file(vo, p->global, "cache", ""); } @@ -2111,9 +2111,7 @@ static const struct pl_hook *load_hook(struct priv *p, const char *path) return p->user_hooks[i].hook; } - char *fname = mp_get_user_path(NULL, p->global, path); - bstr shader = stream_read_file(fname, p, p->global, 1000000000); // 1GB - talloc_free(fname); + bstr shader = stream_read_file(path, p, p->global, 1000000000); // 1GB const struct pl_hook *hook = NULL; if (shader.len) @@ -2156,10 +2154,9 @@ static void update_icc_opts(struct priv *p, const struct mp_icc_opts *opts) if (p->icc_path && strcmp(opts->profile, p->icc_path) == 0) return; // ICC profile hasn't changed - char *fname = mp_get_user_path(NULL, p->global, opts->profile); + char *fname = opts->profile; MP_VERBOSE(p, "Opening ICC profile '%s'\n", fname); struct bstr icc = stream_read_file(fname, p, p->global, 100000000); // 100 MB - talloc_free(fname); update_icc(p, icc); // Update cached path @@ -2182,7 +2179,7 @@ static void update_lut(struct priv *p, struct user_lut *lut) talloc_replace(p, lut->path, lut->opt); // Load LUT file - char *fname = mp_get_user_path(NULL, p->global, lut->path); + char *fname = lut->path; MP_VERBOSE(p, "Loading custom LUT '%s'\n", fname); const int lut_max_size = 1536 << 20; // 1.5 GiB, matches lut cache limit struct bstr lutdata = stream_read_file(fname, NULL, p->global, lut_max_size); @@ -2192,7 +2189,6 @@ static void update_lut(struct priv *p, struct user_lut *lut) } else { lut->lut = pl_lut_parse_cube(p->pllog, lutdata.start, lutdata.len); } - talloc_free(fname); talloc_free(lutdata.start); }