summaryrefslogtreecommitdiffstats
path: root/osdep/path-win.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-26 18:31:28 +0200
committerwm4 <wm4@nowhere>2014-06-26 19:56:45 +0200
commit3e1c0e585393928c9931122df74a11f8a28e489d (patch)
treedcb0b37737ecf6b2ef5eea870c0edca02f59378e /osdep/path-win.c
parent0dcde951b9593535bd5da1ae609b55d35f7e36b3 (diff)
downloadmpv-3e1c0e585393928c9931122df74a11f8a28e489d.tar.bz2
mpv-3e1c0e585393928c9931122df74a11f8a28e489d.tar.xz
config: make passing talloc context optional for some functions
Until now, the config functions added various allocations to the user- provided talloc context. Make it so that they're all under the returned allocation instead. This allows avoiding having to create an extra temporary context for some callers, and also avoids adding random memory leaks by accidentally passing a NULL context. mp_find_all_config_files() has to be changed not to return a pointer into the middle array for this to work. Make it add paths in order (instead of reverse), and then reverse the array entries after that. Also remove the declarations for the win-specific private functions. Remove STRNULL(); it's barely needed anymore and the functions are not called with NULL filenames anymore.
Diffstat (limited to 'osdep/path-win.c')
-rw-r--r--osdep/path-win.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/osdep/path-win.c b/osdep/path-win.c
index e35bab37a2..eb88a9cfc4 100644
--- a/osdep/path-win.c
+++ b/osdep/path-win.c
@@ -24,7 +24,7 @@
// Warning: do not use PATH_MAX. Cygwin messed it up.
-char *mp_get_win_exe_dir(void *talloc_ctx)
+static char *mp_get_win_exe_dir(void *talloc_ctx)
{
wchar_t w_exedir[MAX_PATH + 1] = {0};
@@ -41,12 +41,13 @@ char *mp_get_win_exe_dir(void *talloc_ctx)
return mp_to_utf8(talloc_ctx, w_exedir);
}
-char *mp_get_win_exe_subdir(void *talloc_ctx)
+
+static char *mp_get_win_exe_subdir(void *talloc_ctx)
{
return talloc_asprintf(talloc_ctx, "%s/mpv", mp_get_win_exe_dir(talloc_ctx));
}
-char *mp_get_win_app_dir(void *talloc_ctx)
+static char *mp_get_win_app_dir(void *talloc_ctx)
{
wchar_t w_appdir[MAX_PATH + 1] = {0};
@@ -57,11 +58,9 @@ char *mp_get_win_app_dir(void *talloc_ctx)
return talloc_asprintf(talloc_ctx, "%s/mpv", mp_to_utf8(talloc_ctx, w_appdir));
}
-
-
-void mp_add_win_config_dirs(void *talloc_ctx, struct mpv_global *global,
- char **dirs, int i)
+void mp_add_win_config_dirs(struct mpv_global *global, char **dirs, int i)
{
+ void *talloc_ctx = dirs;
if ((dirs[i] = mp_get_win_exe_subdir(talloc_ctx)))
i++;
if ((dirs[i] = mp_get_win_exe_dir(talloc_ctx)))