반응형
int
fclose(FILE *fp)
#include <errno.h> #include <stdio.h> #include <stdlib.h> #include "local.h" int fclose(FILE *fp) { int r; if (fp->_flags == 0) { /* not open! */ errno = EBADF; return (EOF); } WCIO_FREE(fp); r = fp->_flags & __SWR ? __sflush(fp) : 0; if (fp->_close != NULL && (*fp->_close)(fp->_cookie) < 0) r = EOF; if (fp->_flags & __SMBF) free((char *)fp->_bf._base); if (HASUB(fp)) FREEUB(fp); if (HASLB(fp)) FREELB(fp); fp->_flags = 0; /* Release this FILE for reuse. */ fp->_r = fp->_w = 0; /* Mess up if reaccessed. */ return (r); }
반응형