Loading...
stdlib/FreeBSD/putenv.c Libc-1725.40.4 Libc-825.26
--- Libc/Libc-1725.40.4/stdlib/FreeBSD/putenv.c
+++ Libc/Libc-825.26/stdlib/FreeBSD/putenv.c
@@ -38,9 +38,7 @@
 #include <sys/types.h>
 #include <db.h>
 #include <crt_externs.h>
-#include <errno.h>
-
-#include "libc_private.h"
+#include <errno.h> 
 
 extern struct owned_ptr *__env_owned;
 
@@ -48,8 +46,8 @@
 extern char **_saved_environ;
 #endif /* LEGACY_CRT1_ENVIRON */
 
-__private_extern__ int __init__env_owned_locked(int);
-__private_extern__ int __setenv_locked(const char *, const char *, int, int, char ***, struct owned_ptr *);
+__private_extern__ int __init__env_owned(int);
+__private_extern__ int __setenv(const char *, const char *, int, int, char ***, struct owned_ptr *);
 
 #ifndef BUILDING_VARIANT
 /*
@@ -60,23 +58,18 @@
 int
 _putenvp(char *str, char ***envp, void *state)
 {
-	environ_lock_np();
-	if (__init__env_owned_locked(1)) {
-		environ_unlock_np();
-		return (-1);
-	}
-	int ret = __setenv_locked(str, NULL, 1, 0, envp,
-			(state ? (struct owned_ptr *)state : __env_owned));
-	environ_unlock_np();
-	return ret;
+	if (__init__env_owned(1)) return (-1);
+	return (__setenv(str, NULL, 1, 0, envp, (state ? (struct owned_ptr *)state : __env_owned)));
 }
 #endif /* BUILDING_VARIANT */
 
 int
-putenv(char *str)
+putenv(str)
+	char *str;
 {
+#ifdef LEGACY_CRT1_ENVIRON
 	int ret;
-	int copy;
+#endif /* LEGACY_CRT1_ENVIRON */
 
 #if __DARWIN_UNIX03
 	if (str == NULL || *str == 0 || index(str, '=') == NULL) {
@@ -87,22 +80,21 @@
 	if (index(str, '=') == NULL)
 		return (-1);
 #endif /* __DARWIN_UNIX03 */
-
+	if (__init__env_owned(1)) return (-1);
+#ifdef LEGACY_CRT1_ENVIRON
+	ret =
+#else /* !LEGACY_CRT1_ENVIRON */
+	return
+#endif /* !LEGACY_CRT1_ENVIRON */
+	    __setenv(str, NULL, 1,
 #if __DARWIN_UNIX03
-	copy = 0;
+		0,
 #else /* !__DARWIN_UNIX03 */
-	copy = -1;
+		-1,
 #endif /* __DARWIN_UNIX03 */
-
-	environ_lock_np();
-	if (__init__env_owned_locked(1)) {
-		environ_unlock_np();
-		return (-1);
-	}
-	ret = __setenv_locked(str, NULL, 1, copy, _NSGetEnviron(), __env_owned);
+		_NSGetEnviron(), __env_owned);
 #ifdef LEGACY_CRT1_ENVIRON
 	_saved_environ = *_NSGetEnviron();
+	return ret;
 #endif /* LEGACY_CRT1_ENVIRON */
-	environ_unlock_np();
-	return ret;
 }