X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/ad3c9f2af814c84582fdd1649e49ec4f68572c5a..507116e319a1470bb0a5040d4d23e5c76955ef97:/stdio/FreeBSD/freopen.c diff --git a/stdio/FreeBSD/freopen.c b/stdio/FreeBSD/freopen.c index 3451106..b401304 100644 --- a/stdio/FreeBSD/freopen.c +++ b/stdio/FreeBSD/freopen.c @@ -70,11 +70,10 @@ freopen(file, mode, fp) return (NULL); } + pthread_once(&__sdidinit, __sinit); + FLOCKFILE(fp); - if (!__sdidinit) - __sinit(); - /* * If the filename is a NULL pointer, the caller is asking us to * re-open the same file with a different mode. We allow this only @@ -195,8 +194,8 @@ finish: memset(&fp->_mbstate, 0, sizeof(mbstate_t)); if (f < 0) { /* did not get it after all */ - __sfprelease(fp); /* set it free */ FUNLOCKFILE(fp); + __sfprelease(fp); /* set it free */ errno = sverrno; /* restore in case _close clobbered */ return (NULL); } @@ -221,8 +220,8 @@ finish: * open. */ if (f > SHRT_MAX) { - __sfprelease(fp); /* set it free */ FUNLOCKFILE(fp); + __sfprelease(fp); /* set it free */ errno = EMFILE; return (NULL); }