authorgravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2022-02-18 14:58:13-07:00
committergravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2022-05-11 18:41:23-06:00
loga38e6a64d32974bebb1c338dac5e56a35c8bcac4
tree990be30e6441da04b22817e60986275a34605430
parent8492ced0755924b3c4c0d67fb306d65bffd0933a

document that on Windows, all key arguments in EnvMap must be valid utf8


1 files changed, 5 insertions(+), 0 deletions(-)

lib/std/process.zig+5
...@@ -128,6 +128,7 @@ pub const EnvMap = struct {...@@ -128,6 +128,7 @@ pub const EnvMap = struct {
128 /// Same as `put` but the key and value become owned by the EnvMap rather128 /// Same as `put` but the key and value become owned by the EnvMap rather
129 /// than being copied.129 /// than being copied.
130 /// If `putMove` fails, the ownership of key and value does not transfer.130 /// If `putMove` fails, the ownership of key and value does not transfer.
131 /// On Windows `key` must be a valid UTF-8 string.
131 pub fn putMove(self: *EnvMap, key: []u8, value: []u8) !void {132 pub fn putMove(self: *EnvMap, key: []u8, value: []u8) !void {
132 const get_or_put = try self.hash_map.getOrPut(key);133 const get_or_put = try self.hash_map.getOrPut(key);
133 if (get_or_put.found_existing) {134 if (get_or_put.found_existing) {
...@@ -139,6 +140,7 @@ pub const EnvMap = struct {...@@ -139,6 +140,7 @@ pub const EnvMap = struct {
139 }140 }
140141
141 /// `key` and `value` are copied into the EnvMap.142 /// `key` and `value` are copied into the EnvMap.
143 /// On Windows `key` must be a valid UTF-8 string.
142 pub fn put(self: *EnvMap, key: []const u8, value: []const u8) !void {144 pub fn put(self: *EnvMap, key: []const u8, value: []const u8) !void {
143 const value_copy = try self.copy(value);145 const value_copy = try self.copy(value);
144 errdefer self.free(value_copy);146 errdefer self.free(value_copy);
...@@ -156,6 +158,7 @@ pub const EnvMap = struct {...@@ -156,6 +158,7 @@ pub const EnvMap = struct {
156158
157 /// Find the address of the value associated with a key.159 /// Find the address of the value associated with a key.
158 /// The returned pointer is invalidated if the map resizes.160 /// The returned pointer is invalidated if the map resizes.
161 /// On Windows `key` must be a valid UTF-8 string.
159 pub fn getPtr(self: EnvMap, key: []const u8) ?*[]const u8 {162 pub fn getPtr(self: EnvMap, key: []const u8) ?*[]const u8 {
160 return self.hash_map.getPtr(key);163 return self.hash_map.getPtr(key);
161 }164 }
...@@ -163,12 +166,14 @@ pub const EnvMap = struct {...@@ -163,12 +166,14 @@ pub const EnvMap = struct {
163 /// Return the map's copy of the value associated with166 /// Return the map's copy of the value associated with
164 /// a key. The returned string is invalidated if this167 /// a key. The returned string is invalidated if this
165 /// key is removed from the map.168 /// key is removed from the map.
169 /// On Windows `key` must be a valid UTF-8 string.
166 pub fn get(self: EnvMap, key: []const u8) ?[]const u8 {170 pub fn get(self: EnvMap, key: []const u8) ?[]const u8 {
167 return self.hash_map.get(key);171 return self.hash_map.get(key);
168 }172 }
169173
170 /// Removes the item from the map and frees its value.174 /// Removes the item from the map and frees its value.
171 /// This invalidates the value returned by get() for this key.175 /// This invalidates the value returned by get() for this key.
176 /// On Windows `key` must be a valid UTF-8 string.
172 pub fn remove(self: *EnvMap, key: []const u8) void {177 pub fn remove(self: *EnvMap, key: []const u8) void {
173 const kv = self.hash_map.fetchRemove(key) orelse return;178 const kv = self.hash_map.fetchRemove(key) orelse return;
174 self.free(kv.key);179 self.free(kv.key);