diff options
author | Tim Mayberry <mojofunk@gmail.com> | 2015-08-18 14:04:21 +1000 |
---|---|---|
committer | Tim Mayberry <mojofunk@gmail.com> | 2015-08-18 15:10:55 +1000 |
commit | 36e4c11a2ac8e1a2310d948b6f039d28be4cf521 (patch) | |
tree | 1c7ec787a5766217c0cf39f41a2ad3b79d4c4520 /libs/ardour/filesystem_paths.cc | |
parent | 1d05b5d25de1dad9ca6474a4b714d940d43206c0 (diff) |
Add utility function to get windows packaging directory to avoid memory leaks
There were a few other small leaks in pbd and evoral test code but I didn't
bother changing them. Perhaps this function would be better off in PBD:: so it
can be used everywhere.
Diffstat (limited to 'libs/ardour/filesystem_paths.cc')
-rw-r--r-- | libs/ardour/filesystem_paths.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/libs/ardour/filesystem_paths.cc b/libs/ardour/filesystem_paths.cc index fe1afd85d8..7e9b4e1857 100644 --- a/libs/ardour/filesystem_paths.cc +++ b/libs/ardour/filesystem_paths.cc @@ -200,7 +200,7 @@ std::string ardour_dll_directory () { #ifdef PLATFORM_WINDOWS - std::string dll_dir_path(g_win32_get_package_installation_directory_of_module(NULL)); + std::string dll_dir_path(windows_package_directory_path()); dll_dir_path = Glib::build_filename (dll_dir_path, "lib"); return Glib::build_filename (dll_dir_path, LIBARDOUR); #else @@ -217,10 +217,27 @@ ardour_dll_directory () Searchpath windows_search_path () { - std::string dll_dir_path(g_win32_get_package_installation_directory_of_module(NULL)); + std::string dll_dir_path(windows_package_directory_path()); dll_dir_path = Glib::build_filename (dll_dir_path, "share"); return Glib::build_filename (dll_dir_path, LIBARDOUR); } + +std::string +windows_package_directory_path () +{ + char* package_dir = + g_win32_get_package_installation_directory_of_module (NULL); + + if (package_dir == NULL) { + fatal << string_compose (_("Cannot determine %1 package directory"), + PROGRAM_NAME) << endmsg; + // not reached + } + + std::string package_dir_path(package_dir); + g_free(package_dir); + return package_dir_path; +} #endif Searchpath |