closedir.c (9272) | closedir.c (17141) |
---|---|
1/* 2 * Copyright (c) 1983, 1993 3 * Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 26 unchanged lines hidden (view full) --- 35static char sccsid[] = "@(#)closedir.c 8.1 (Berkeley) 6/10/93"; 36#endif /* LIBC_SCCS and not lint */ 37 38#include <sys/types.h> 39#include <dirent.h> 40#include <stdlib.h> 41#include <unistd.h> 42 | 1/* 2 * Copyright (c) 1983, 1993 3 * Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 26 unchanged lines hidden (view full) --- 35static char sccsid[] = "@(#)closedir.c 8.1 (Berkeley) 6/10/93"; 36#endif /* LIBC_SCCS and not lint */ 37 38#include <sys/types.h> 39#include <dirent.h> 40#include <stdlib.h> 41#include <unistd.h> 42 |
43extern void _reclaim_telldir __P(( const DIR * )); 44 |
|
43/* 44 * close a directory. 45 */ 46int 47closedir(dirp) 48 register DIR *dirp; 49{ 50 int fd; 51 52 seekdir(dirp, dirp->dd_rewind); /* free seekdir storage */ 53 fd = dirp->dd_fd; 54 dirp->dd_fd = -1; 55 dirp->dd_loc = 0; 56 free((void *)dirp->dd_buf); 57 free((void *)dirp); 58 _reclaim_telldir(dirp); 59 return(close(fd)); 60} | 45/* 46 * close a directory. 47 */ 48int 49closedir(dirp) 50 register DIR *dirp; 51{ 52 int fd; 53 54 seekdir(dirp, dirp->dd_rewind); /* free seekdir storage */ 55 fd = dirp->dd_fd; 56 dirp->dd_fd = -1; 57 dirp->dd_loc = 0; 58 free((void *)dirp->dd_buf); 59 free((void *)dirp); 60 _reclaim_telldir(dirp); 61 return(close(fd)); 62} |