aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-03-18 09:01:59 +0000
committerUlrich Drepper <drepper@redhat.com>1998-03-18 09:01:59 +0000
commit9eecb5e8f3903a6fe66ac88f9218935130e77042 (patch)
tree67594caa357c4117cf65e55663641086f41b892d
parent488690121208fb26e6f87cdbbf9bf540fa4a7140 (diff)
downloadglibc-9eecb5e8f3903a6fe66ac88f9218935130e77042.zip
glibc-9eecb5e8f3903a6fe66ac88f9218935130e77042.tar.gz
glibc-9eecb5e8f3903a6fe66ac88f9218935130e77042.tar.bz2
Update.
1998-03-18 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/opendir.c (__opendir): Don't block on FIFOs etc. Optimize memmory handling. * sysdeps/unix/closedir.c: Optmize memory handling.
-rw-r--r--ChangeLog6
-rw-r--r--posix/wordexp.c2
-rw-r--r--sysdeps/unix/closedir.c3
-rw-r--r--sysdeps/unix/opendir.c42
4 files changed, 26 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index a6d6299..07fd47c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+1998-03-18 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/unix/opendir.c (__opendir): Don't block on FIFOs etc.
+ Optimize memmory handling.
+ * sysdeps/unix/closedir.c: Optmize memory handling.
+
1998-03-17 Ulrich Drepper <drepper@cygnus.com>
* posix/wordexp.c (parse_param): Fix off-by-on error in $@
diff --git a/posix/wordexp.c b/posix/wordexp.c
index 51cdc93..1c69af8 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -1377,7 +1377,7 @@ envsubst:
if (s == NULL)
return WRDE_NOSPACE;
*word = memcpy (s, __libc_argv[p], len);
- *max_length = *word_length = len;
+ *max_length = *word_length = len - 1;
}
}
diff --git a/sysdeps/unix/closedir.c b/sysdeps/unix/closedir.c
index a390318..a63fa53 100644
--- a/sysdeps/unix/closedir.c
+++ b/sysdeps/unix/closedir.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1995, 1996, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -39,7 +39,6 @@ __closedir (DIR *dirp)
__libc_lock_lock (dirp->lock);
fd = dirp->fd;
- free ((void *) dirp->data);
__libc_lock_fini (dirp->lock);
diff --git a/sysdeps/unix/opendir.c b/sysdeps/unix/opendir.c
index b4e691a..2469917 100644
--- a/sysdeps/unix/opendir.c
+++ b/sysdeps/unix/opendir.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 94, 95, 96, 98 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -36,6 +36,8 @@ __opendir (const char *name)
DIR *dirp;
struct stat statbuf;
int fd;
+ size_t allocation;
+ int save_errno;
if (name[0] == '\0')
{
@@ -45,7 +47,7 @@ __opendir (const char *name)
return NULL;
}
- fd = __open (name, O_RDONLY);
+ fd = __open (name, O_RDONLY|O_NDELAY);
if (fd < 0)
return NULL;
@@ -56,39 +58,31 @@ __opendir (const char *name)
goto lose;
if (! S_ISDIR (statbuf.st_mode))
{
- __set_errno (ENOTDIR);
- goto lose;
- }
-
- dirp = (DIR *) calloc (1, sizeof (DIR)); /* Zero-fill. */
- if (dirp == NULL)
- lose:
- {
- int save = errno;
- (void) __close (fd);
- __set_errno (save);
- return NULL;
+ save_errno = ENOTDIR;
+ goto lose2;
}
#ifdef _STATBUF_ST_BLKSIZE
if (statbuf.st_blksize < sizeof (struct dirent))
- dirp->allocation = sizeof (struct dirent);
+ allocation = sizeof (struct dirent);
else
- dirp->allocation = statbuf.st_blksize;
+ allocation = statbuf.st_blksize;
#else
- dirp->allocation = (BUFSIZ < sizeof (struct dirent) ?
- sizeof (struct dirent) : BUFSIZ);
+ allocation = (BUFSIZ < sizeof (struct dirent)
+ ? sizeof (struct dirent) : BUFSIZ);
#endif
- dirp->data = (char *) malloc (dirp->allocation);
- if (dirp->data == NULL)
+
+ dirp = (DIR *) calloc (1, sizeof (DIR) + allocation); /* Zero-fill. */
+ if (dirp == NULL)
+ lose:
{
- int save = errno;
- free (dirp);
+ save_errno = errno;
+ lose2:
(void) __close (fd);
- __set_errno (save);
+ __set_errno (save_errno);
return NULL;
}
-
+ dirp->data = (char *) (dirp + 1);
dirp->fd = fd;
__libc_lock_init (dirp->lock);