Skip to content

Commit

Permalink
More env fixes for Win32
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaTheFoxgirl committed Dec 15, 2024
1 parent 0d1d618 commit fedc5f8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/numem/env.d
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ nstring nuGetEnvironmentVariable(nstring key) @nogc {

// Try getting the size of the env var.
// if this fails, the env var is probably empty.
uint bufSize = GetEnvironmentVariableW(utf16k.ptr, null, 0);
uint bufSize = GetEnvironmentVariableW(cast(wchar*)utf16k.ptr, null, 0);
if (bufSize == 0)
return nstring.init;

// Windows includes the null terminator, but n*string does too
// so to not have 2 null terminators, subtract 1.
nwstring envstr = nwstring(bufSize-1);
bufSize = GetEnvironmentVariableW(cast(wchar*)utf16k.ptr, cast(wchar*)envstr.ptr, envstr.length+1);
bufSize = GetEnvironmentVariableW(cast(wchar*)utf16k.ptr, cast(wchar*)envstr.ptr, cast(uint)envstr.length+1);

nogc_delete(utf16k);
return envstr.toUTF8;
Expand Down

0 comments on commit fedc5f8

Please sign in to comment.