pub fn getAlloc(environ: Environ, gpa: Allocator, key: []const u8) GetAllocError![]u8 OutOfMemoryEnvironmentVariableMissingInvalidWtf8On Windows, environment variable keys provided by the user must be valid WTF-8. This error is unreachable if the key is statically known to be valid.
713
714
715
716
717
718
719pub fn getAlloc(environ: Environ, gpa: Allocator, key: []const u8) GetAllocError![]u8 {
if (native_os == .windows and !unicode.wtf8ValidateSlice(key)) return error.InvalidWtf8;
var map = createMap(environ, gpa) catch return error.OutOfMemory;
defer map.deinit();
const val = map.get(key) orelse return error.EnvironmentVariableMissing;
return gpa.dupe(u8, val);
}
Caller owns returned memory.
On Windows:
keyis not valid WTF-8, thenerror.InvalidWtf8is returned.On other platforms, the value is an opaque sequence of bytes with no particular encoding.
See also:
createMap