hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit ece74311fdef4309dac57ec61cf9b9272b4e2361
parent 8683c18641b931e2ddaf574858f4edadfd40c1e6
Author: Sebastian <sebastian@sebsite.pw>
Date:   Thu, 31 Aug 2023 02:11:40 -0400

os::exec: don't allocate in unsetenv

This is the same as how os::unsetenv is implemented

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mos/exec/cmd.ha | 4+---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/os/exec/cmd.ha b/os/exec/cmd.ha @@ -101,10 +101,8 @@ export fn unsetenv(cmd: *command, key: str) (void | errors::invalid) = { if (strings::contains(key, '=', '\0')) return errors::invalid; // XXX: This can be a binary search - let fullkey = strings::concat(key, "="); - defer free(fullkey); for (let i = 0z; i < len(cmd.env); i += 1) { - if (strings::hasprefix(cmd.env[i], fullkey)) { + if (strings::cut(cmd.env[i], "=").0 == key) { free(cmd.env[i]); delete(cmd.env[i]); break;