xref: /csrg-svn/lib/libc/gen/closedir.c (revision 42620)
121339Sdist /*
221339Sdist  * Copyright (c) 1983 Regents of the University of California.
334790Sbostic  * All rights reserved.
434790Sbostic  *
5*42620Sbostic  * %sccs.include.redist.c%
621339Sdist  */
721339Sdist 
826544Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*42620Sbostic static char sccsid[] = "@(#)closedir.c	5.8 (Berkeley) 06/01/90";
1034790Sbostic #endif /* LIBC_SCCS and not lint */
115749Smckusick 
1242384Sbostic #include <sys/types.h>
1336545Smckusick #include <dirent.h>
145749Smckusick 
155749Smckusick /*
165749Smckusick  * close a directory.
175749Smckusick  */
185749Smckusick closedir(dirp)
196098Smckusic 	register DIR *dirp;
205749Smckusick {
2142384Sbostic 	int fd;
2238435Smckusick 
2342384Sbostic 	fd = dirp->dd_fd;
246098Smckusic 	dirp->dd_fd = -1;
256098Smckusic 	dirp->dd_loc = 0;
2642384Sbostic 	(void)free((void *)dirp->dd_buf);
2742384Sbostic 	(void)free((void *)dirp);
2842384Sbostic 	return(close(fd));
295749Smckusick }
30