diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index 29062bbfc17..d093ac8d2e9 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -119,7 +119,7 @@ void lp_bld_init_native_targets() llvm::InitializeNativeTargetDisassembler(); #if MESA_DEBUG { - char *env_llc_options = getenv("GALLIVM_LLC_OPTIONS"); + char *env_llc_options = os_get_option_dup("GALLIVM_LLC_OPTIONS"); if (env_llc_options) { char *option; char *options[64] = {(char *) "llc"}; // Warning without cast @@ -135,6 +135,7 @@ void lp_bld_init_native_targets() } LLVMParseCommandLineOptions(n + 1, options, NULL); } + free(env_llc_options); } #endif lp_run_atexit_for_destructors(); diff --git a/src/util/tests/process_test.c b/src/util/tests/process_test.c index dd4e7bf8c7a..ec55a25b276 100644 --- a/src/util/tests/process_test.c +++ b/src/util/tests/process_test.c @@ -24,6 +24,7 @@ /* A collection of unit tests for u_process.c */ #include "util/detect_os.h" +#include "util/os_misc.h" #include "util/u_process.h" #include #include @@ -88,13 +89,12 @@ test_util_get_process_exec_path (void) return; } posixify_path(path); - char* build_path = getenv("BUILD_FULL_PATH"); + char* build_path = os_get_option_dup("BUILD_FULL_PATH"); if (!build_path) { fprintf(stderr, "BUILD_FULL_PATH environment variable should be set\n"); error = true; return; } - build_path = strdup(build_path); posixify_path(build_path); #ifdef __CYGWIN__ int i = strlen(build_path) - 4; diff --git a/src/vulkan/device-select-layer/device_select_layer.c b/src/vulkan/device-select-layer/device_select_layer.c index 03c71631ee0..1b95b9ca1b6 100644 --- a/src/vulkan/device-select-layer/device_select_layer.c +++ b/src/vulkan/device-select-layer/device_select_layer.c @@ -157,12 +157,10 @@ device_select_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, info->debug = debug_get_bool_option("MESA_VK_DEVICE_SELECT_DEBUG", false) || debug_get_bool_option("DRI_PRIME_DEBUG", false); - info->selection = getenv("MESA_VK_DEVICE_SELECT"); - info->dri_prime = getenv("DRI_PRIME"); + info->selection = os_get_option_dup("MESA_VK_DEVICE_SELECT"); + info->dri_prime = os_get_option_dup("DRI_PRIME"); info->force_default_device = debug_get_bool_option("MESA_VK_DEVICE_SELECT_FORCE_DEFAULT_DEVICE", false); - info->selection = info->selection ? strdup(info->selection) : NULL; - info->dri_prime = info->dri_prime ? strdup(info->dri_prime) : NULL; #define DEVSEL_GET_CB(func) \ info->func = (PFN_vk##func)info->GetInstanceProcAddr(*pInstance, "vk" #func)