env-util: replace unsetenv_erase() by new getenv_steal_erase() helper

The new helper combines a bunch of steps every invocation of
unsetenv_erase() did so far: getenv() + strdup() + unsetenv_erase().
Let's unify this into one helper that is harder to use incorrectly. It's
in inspired by TAKE_PTR() in a way: get the env var out and invalidate
where it was before.
This commit is contained in:
Lennart Poettering
2022-02-20 12:38:06 +09:00
committed by Yu Watanabe
parent 5cf84d2545
commit e99ca14741
9 changed files with 91 additions and 85 deletions
+2
View File
@@ -70,3 +70,5 @@ int setenv_systemd_exec_pid(bool update_only);
int getenv_path_list(const char *name, char ***ret_paths);
int unsetenv_erase(const char *name);
int getenv_steal_erase(const char *name, char **ret);