summaryrefslogtreecommitdiff
path: root/environment.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2021-01-12 12:27:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-15 21:03:45 (GMT)
commitb9d147fb150c5e0960bc43ad5f3f843487f816f7 (patch)
tree0f5186d384a95ed361a66afcb0940e784bde42ab /environment.h
parent1ff21c05ba99ed2d0ade8318e3cb0c1a3f8d4b80 (diff)
downloadgit-b9d147fb150c5e0960bc43ad5f3f843487f816f7.zip
git-b9d147fb150c5e0960bc43ad5f3f843487f816f7.tar.gz
git-b9d147fb150c5e0960bc43ad5f3f843487f816f7.tar.bz2
environment: make `getenv_safe()` a public function
The `getenv_safe()` helper function helps to safely retrieve multiple environment values without the need to depend on platform-specific behaviour for the return value's lifetime. We'll make use of this function in a following patch, so let's make it available by making it non-static and adding a declaration. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'environment.h')
-rw-r--r--environment.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/environment.h b/environment.h
new file mode 100644
index 0000000..d438b5c
--- /dev/null
+++ b/environment.h
@@ -0,0 +1,12 @@
+#ifndef ENVIRONMENT_H
+#define ENVIRONMENT_H
+
+#include "strvec.h"
+
+/*
+ * Wrapper of getenv() that returns a strdup value. This value is kept
+ * in argv to be freed later.
+ */
+const char *getenv_safe(struct strvec *argv, const char *name);
+
+#endif