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>
Patrick Steinhardt committed
Jan 12, 2021 at 13:27 UTC
b9d147fb150c5e0960bc43ad5f3f843487f816f7
2 files changed
+14
-5
environment.c
+2
-5
@@ -9,6 +9,7 @@
9
*/
10
#include "cache.h"
11
#include "branch.h"
12
+#include "environment.h"
13
#include "repository.h"
14
#include "config.h"
15
#include "refs.h"
@@ -152,11 +153,7 @@ static char *expand_namespace(const char *raw_namespace)
153
return strbuf_detach(&buf, NULL);
154
}
155
155
-/*
156
- * Wrapper of getenv() that returns a strdup value. This value is kept
157
- * in argv to be freed later.
158
- */
159
-static const char *getenv_safe(struct strvec *argv, const char *name)
156
+const char *getenv_safe(struct strvec *argv, const char *name)
157
{
158
const char *value = getenv(name);
159
environment.h
new
+12
@@ -0,0 +1,12 @@
1
+#ifndef ENVIRONMENT_H
2
+#define ENVIRONMENT_H
3
+
4
+#include "strvec.h"
5
+
6
+/*
7
+ * Wrapper of getenv() that returns a strdup value. This value is kept
8
+ * in argv to be freed later.
9
+ */
10
+const char *getenv_safe(struct strvec *argv, const char *name);
11
+
12
+#endif