mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-24 03:27:12 +01:00
Improve impl of get_environmental_variable()
This commit is contained in:
parent
da26d09716
commit
ff3b3ecb55
@ -75,7 +75,6 @@ namespace vcpkg::System
|
||||
|
||||
optional<std::wstring> get_environmental_variable(const wchar_t* varname) noexcept
|
||||
{
|
||||
std::wstring ret;
|
||||
wchar_t* buffer;
|
||||
_wdupenv_s(&buffer, nullptr, varname);
|
||||
|
||||
@ -83,10 +82,8 @@ namespace vcpkg::System
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ret = buffer;
|
||||
free(buffer);
|
||||
return std::make_unique<std::wstring>(ret);
|
||||
std::unique_ptr<wchar_t, void(__cdecl *)(void*)> bufptr(buffer, free);
|
||||
return std::make_unique<std::wstring>(buffer);
|
||||
}
|
||||
|
||||
void set_environmental_variable(const wchar_t* varname, const wchar_t* varvalue) noexcept
|
||||
|
Loading…
x
Reference in New Issue
Block a user