Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/posix/closedir.c')
-rw-r--r--newlib/libc/posix/closedir.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/newlib/libc/posix/closedir.c b/newlib/libc/posix/closedir.c
index 634f5ad12..7801da043 100644
--- a/newlib/libc/posix/closedir.c
+++ b/newlib/libc/posix/closedir.c
@@ -52,25 +52,19 @@ int
_DEFUN(closedir, (dirp),
register DIR *dirp)
{
- int fd, rc;
+ int rc;
#ifdef HAVE_DD_LOCK
__lock_acquire_recursive(dirp->dd_lock);
#endif
- rc = 0;
- fd = dirp->dd_fd;
- if (fd != -1) {
- dirp->dd_fd = -1;
- dirp->dd_loc = 0;
- (void)free((void *)dirp->dd_buf);
- (void)free((void *)dirp);
- rc = close(fd);
- _cleanupdir(dirp);
- }
+ rc = close(dirp->dd_fd);
+ _cleanupdir(dirp);
+ free((void *)dirp->dd_buf);
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
__lock_close_recursive(dirp->dd_lock);
#endif
+ free((void *)dirp);
return rc;
}