From 36e4c11a2ac8e1a2310d948b6f039d28be4cf521 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Tue, 18 Aug 2015 14:04:21 +1000 Subject: 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. --- libs/ardour/filesystem_paths.cc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'libs/ardour/filesystem_paths.cc') 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 -- cgit v1.2.3