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 {
128128 /// Same as `put` but the key and value become owned by the EnvMap rather
129129 /// than being copied.
130130 /// If `putMove` fails, the ownership of key and value does not transfer.
131 /// On Windows `key` must be a valid UTF-8 string.
131132 pub fn putMove(self: *EnvMap, key: []u8, value: []u8) !void {
132133 const get_or_put = try self.hash_map.getOrPut(key);
133134 if (get_or_put.found_existing) {
......@@ -139,6 +140,7 @@ pub const EnvMap = struct {
139140 }
140141
141142 /// `key` and `value` are copied into the EnvMap.
143 /// On Windows `key` must be a valid UTF-8 string.
142144 pub fn put(self: *EnvMap, key: []const u8, value: []const u8) !void {
143145 const value_copy = try self.copy(value);
144146 errdefer self.free(value_copy);
......@@ -156,6 +158,7 @@ pub const EnvMap = struct {
156158
157159 /// Find the address of the value associated with a key.
158160 /// The returned pointer is invalidated if the map resizes.
161 /// On Windows `key` must be a valid UTF-8 string.
159162 pub fn getPtr(self: EnvMap, key: []const u8) ?*[]const u8 {
160163 return self.hash_map.getPtr(key);
161164 }
......@@ -163,12 +166,14 @@ pub const EnvMap = struct {
163166 /// Return the map's copy of the value associated with
164167 /// a key. The returned string is invalidated if this
165168 /// key is removed from the map.
169 /// On Windows `key` must be a valid UTF-8 string.
166170 pub fn get(self: EnvMap, key: []const u8) ?[]const u8 {
167171 return self.hash_map.get(key);
168172 }
169173
170174 /// Removes the item from the map and frees its value.
171175 /// This invalidates the value returned by get() for this key.
176 /// On Windows `key` must be a valid UTF-8 string.
172177 pub fn remove(self: *EnvMap, key: []const u8) void {
173178 const kv = self.hash_map.fetchRemove(key) orelse return;
174179 self.free(kv.key);