ack/lang/cem/libcc/stdio/fclose.c

24 lines
382 B
C
Raw Normal View History

1987-03-31 10:45:53 +00:00
/* $Header$ */
1987-01-27 15:57:55 +00:00
#include <stdio.h>
fclose(fp)
FILE *fp;
{
register int i;
for (i=0; i<_NFILES; i++)
if (fp == _io_table[i]) {
_io_table[i] = 0;
break;
}
if (i >= _NFILES)
return(EOF);
fflush(fp);
close(fileno(fp));
if ( io_testflag(fp,IO_MYBUF) && fp->_buf )
free( fp->_buf );
1987-07-16 16:08:13 +00:00
if (fp != &_stdin && fp != &_stdout && fp != &_stderr) free(fp);
1987-01-27 15:57:55 +00:00
return(NULL);
}