mirror of
https://github.com/NixOS/nix
synced 2025-07-05 20:41:47 +02:00
libutil/windows: Finally use the correct constructor for std::wstring
C++ is very intuitive /s [1]. Fixes #12631. [1]: https://godbolt.org/z/jMa9GP5sq
This commit is contained in:
parent
cacab33f0d
commit
24fbb456ba
1 changed files with 4 additions and 2 deletions
|
@ -13,8 +13,10 @@ std::optional<OsString> getEnvOs(const OsString & key)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a buffer to hold the environment variable value
|
/* Allocate a buffer to hold the environment variable value.
|
||||||
std::wstring value{bufferSize, L'\0'};
|
WARNING: Do not even think about using uniform initialization here,
|
||||||
|
we DONT want to call the initializer list ctor accidentally. */
|
||||||
|
std::wstring value(bufferSize, L'\0');
|
||||||
|
|
||||||
// Retrieve the environment variable value
|
// Retrieve the environment variable value
|
||||||
DWORD resultSize = GetEnvironmentVariableW(key.c_str(), &value[0], bufferSize);
|
DWORD resultSize = GetEnvironmentVariableW(key.c_str(), &value[0], bufferSize);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue