home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / unixlib36d / src / stdio / c / fclose next >
Encoding:
Text File  |  1994-03-08  |  425 b   |  32 lines

  1. static char sccs_id[] = "@(#) fclose.c 1.1 " __DATE__ " HJR";
  2.  
  3. /* fclose.c (c) Copyright 1990 H.Rogers */
  4.  
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7.  
  8. #include "fcntl.h"
  9.  
  10. extern int close (int);
  11.  
  12. __STDIOLIB__
  13.  
  14. int
  15. fclose (register FILE * f)
  16. {
  17.   if (fflush (f))
  18.     return (-1);
  19.  
  20.   if (f->i_base)
  21.     free (f->i_base);
  22.   if (f->o_base)
  23.     free (f->o_base);
  24.  
  25.   if (close (f->fd))
  26.     return (-1);
  27.  
  28.   f->flag = 0;
  29.  
  30.   return (0);
  31. }
  32.