Olivier F. R. Dierick : shell32: Add helper functions for XDG directories lookup and resource deallocation.
Alexandre Julliard
julliard at winehq.org
Thu Feb 20 18:26:14 CST 2020
Module: wine
Branch: master
Commit: 8c7c6e9b79c0818a5c0da0a3af812d28053bbf40
URL: https://source.winehq.org/git/wine.git/?a=commit;h=8c7c6e9b79c0818a5c0da0a3af812d28053bbf40
Author: Olivier F. R. Dierick <o.dierick at piezo-forte.be>
Date: Wed Feb 19 00:16:37 2020 +0100
shell32: Add helper functions for XDG directories lookup and resource deallocation.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=22974
Signed-off-by: Olivier F. R. Dierick <o.dierick at piezo-forte.be>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/shell32/shellpath.c | 48 +++++++++++++++++++++++++++++++++++++++---------
1 file changed, 39 insertions(+), 9 deletions(-)
diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c
index 9bec7091ae..8caf68dc55 100644
--- a/dlls/shell32/shellpath.c
+++ b/dlls/shell32/shellpath.c
@@ -3948,6 +3948,43 @@ end:
return hr;
}
+/*************************************************************************
+ * _SHGetXDGUserDirs [Internal]
+ *
+ * Get XDG directories paths from XDG configuration.
+ *
+ * PARAMS
+ * xdg_dirs [I] Array of XDG directories to look for.
+ * num_dirs [I] Number of elements in xdg_dirs.
+ * xdg_results [O] An array of the XDG directories paths.
+ */
+static inline void _SHGetXDGUserDirs(const char * const *xdg_dirs, const unsigned int num_dirs, char *** xdg_results) {
+ HRESULT hr;
+
+ hr = XDG_UserDirLookup(xdg_dirs, num_dirs, xdg_results);
+ if (FAILED(hr)) *xdg_results = NULL;
+}
+
+/*************************************************************************
+ * _SHFreeXDGUserDirs [Internal]
+ *
+ * Free resources allocated by XDG_UserDirLookup().
+ *
+ * PARAMS
+ * num_dirs [I] Number of elements in xdg_results.
+ * xdg_results [I] An array of the XDG directories paths.
+ */
+static inline void _SHFreeXDGUserDirs(const unsigned int num_dirs, char ** xdg_results) {
+ UINT i;
+
+ if (xdg_results)
+ {
+ for (i = 0; i < num_dirs; i++)
+ heap_free(xdg_results[i]);
+ heap_free(xdg_results);
+ }
+}
+
/*************************************************************************
* _SHAppendToUnixPath [Internal]
*
@@ -4069,8 +4106,7 @@ static void _SHCreateSymbolicLinks(void)
pszPersonal = wine_get_unix_file_name(wszTempPath);
if (!pszPersonal) return;
- hr = XDG_UserDirLookup(xdg_dirs, num, &xdg_results);
- if (FAILED(hr)) xdg_results = NULL;
+ _SHGetXDGUserDirs(xdg_dirs, num, &xdg_results);
pszHome = getenv("HOME");
if (pszHome && !stat(pszHome, &statFolder) && S_ISDIR(statFolder.st_mode))
@@ -4204,13 +4240,7 @@ static void _SHCreateSymbolicLinks(void)
}
}
- /* Free resources allocated by XDG_UserDirLookup() */
- if (xdg_results)
- {
- for (i = 0; i < num; i++)
- heap_free(xdg_results[i]);
- heap_free(xdg_results);
- }
+ _SHFreeXDGUserDirs(num, xdg_results);
}
/******************************************************************************
More information about the wine-cvs
mailing list