home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / dirent / closedir.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-12  |  308 b   |  23 lines

  1. #include <stdlib.h>
  2. #include <dirent.h>
  3. #include <unistd.h>
  4. #include <errno.h>
  5. #include <syscall.h>
  6.  
  7. static inline
  8. _syscall1(int,close,int,fd)
  9.  
  10. int closedir(DIR * dir)
  11. {
  12.   int fd;
  13.  
  14.   if (!dir) {
  15.     errno = EBADF;
  16.     return -1;
  17.   }
  18.   fd = dir->dd_fd;
  19.   free(dir->dd_buf);
  20.   free(dir);
  21.   return close(fd);
  22. }
  23.