Loading...
stdio/FreeBSD/fopen.c Libc-763.13 Libc-1669.40.2
--- Libc/Libc-763.13/stdio/FreeBSD/fopen.c
+++ Libc/Libc-1669.40.2/stdio/FreeBSD/fopen.c
@@ -30,6 +30,15 @@
  * SUCH DAMAGE.
  */
 
+#ifdef VARIANT_DARWINEXTSN
+#define _DARWIN_UNLIMITED_STREAMS
+#define COUNT	0
+#elif defined(VARIANT_LEGACY)
+#define COUNT	0
+#else
+#define COUNT	1
+#endif
+
 #if defined(LIBC_SCCS) && !defined(lint)
 static char sccsid[] = "@(#)fopen.c	8.1 (Berkeley) 6/4/93";
 #endif /* LIBC_SCCS and not lint */
@@ -47,22 +56,24 @@
 #include "un-namespace.h"
 
 #include "local.h"
+#include "libc_hooks_impl.h"
 
 FILE *
-fopen(file, mode)
-	const char * __restrict file;
-	const char * __restrict mode;
+fopen(const char * __restrict file, const char * __restrict mode)
 {
 	FILE *fp;
 	int f;
 	int flags, oflags;
 
+	libc_hooks_will_read_cstring(file);
+	libc_hooks_will_read_cstring(mode);
+
 	if ((flags = __sflags(mode, &oflags)) == 0)
 		return (NULL);
-	if ((fp = __sfp()) == NULL)
+	if ((fp = __sfp(COUNT)) == NULL)
 		return (NULL);
 	if ((f = _open(file, oflags, DEFFILEMODE)) < 0) {
-		fp->_flags = 0;			/* release */
+		__sfprelease(fp);		/* release */
 		return (NULL);
 	}
 	/*