Loading...
stdio/FreeBSD/tmpnam.c Libc-1725.40.4 Libc-763.13
--- Libc/Libc-1725.40.4/stdio/FreeBSD/tmpnam.c
+++ Libc/Libc-763.13/stdio/FreeBSD/tmpnam.c
@@ -40,39 +40,21 @@
 
 #include <stdio.h>
 #include <unistd.h>
-#include <pthread.h>
-#include <stdlib.h>
-
-#include "libc_hooks_impl.h"
 
 __warn_references(tmpnam,
     "warning: tmpnam() possibly used unsafely; consider using mkstemp()");
 
 extern char *_mktemp(char *);
 
-static char *tmpnam_buf = NULL;
-static pthread_once_t tmpnam_buf_control = PTHREAD_ONCE_INIT;
-
-static void tmpnam_buf_allocate(void)
-{
-	tmpnam_buf = malloc(L_tmpnam);
-}
-
 char *
-tmpnam(char *s)
+tmpnam(s)
+	char *s;
 {
 	static u_long tmpcount;
+	static char buf[L_tmpnam];
 
-	if (s == NULL) {
-		if (pthread_once(&tmpnam_buf_control, tmpnam_buf_allocate)
-			|| !tmpnam_buf) {
-			return NULL;
-		}
-		s = tmpnam_buf;
-	}
-
-	libc_hooks_will_write(s, L_tmpnam);
-
+	if (s == NULL)
+		s = buf;
 	(void)snprintf(s, L_tmpnam, "%stmp.%lu.XXXXXX", P_tmpdir, tmpcount);
 	++tmpcount;
 	return (_mktemp(s));