Loading...
stdlib/FreeBSD/putenv.c Libc-1272.250.1 Libc-825.26
--- Libc/Libc-1272.250.1/stdlib/FreeBSD/putenv.c
+++ Libc/Libc-825.26/stdlib/FreeBSD/putenv.c
@@ -46,10 +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__ void __environ_lock(void);
-__private_extern__ void __environ_unlock(void);
+__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,15 +58,8 @@
 int
 _putenvp(char *str, char ***envp, void *state)
 {
-	__environ_lock();
-	if (__init__env_owned_locked(1)) {
-		__environ_unlock();
-		return (-1);
-	}
-	int ret = __setenv_locked(str, NULL, 1, 0, envp,
-			(state ? (struct owned_ptr *)state : __env_owned));
-	__environ_unlock();
-	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 */
 
@@ -76,8 +67,9 @@
 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) {
@@ -88,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();
-	if (__init__env_owned_locked(1)) {
-		__environ_unlock();
-		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();
-	return ret;
 }