about summary refs log tree commit diff
path: root/sysdeps/unix/opendir.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-08-03 03:35:12 +0000
committerUlrich Drepper <drepper@redhat.com>2007-08-03 03:35:12 +0000
commitfa39685d5c7df2502213418bead44e9543a9b9ec (patch)
tree3a5058c9fe7f0cc0ee1a50f0f068131fecc9d78d /sysdeps/unix/opendir.c
parent9b2e9577b228350b15d88303b00097dd58e8d29b (diff)
downloadglibc-fa39685d5c7df2502213418bead44e9543a9b9ec.tar.gz
glibc-fa39685d5c7df2502213418bead44e9543a9b9ec.tar.xz
glibc-fa39685d5c7df2502213418bead44e9543a9b9ec.zip
* sysdeps/unix/opendir.c (__alloc_dir): Don't initialize ->data.
	Avoid memset, add explicit initialization.
	* sysdeps/unix/dirstream.h (struct __dirstream): Move data elemtn
	to the end and change into zero-sized array.
	Move lock member to fill a hole on 64-bit platforms.
Diffstat (limited to 'sysdeps/unix/opendir.c')
-rw-r--r--sysdeps/unix/opendir.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/sysdeps/unix/opendir.c b/sysdeps/unix/opendir.c
index 59772cda75..36fb6f458d 100644
--- a/sysdeps/unix/opendir.c
+++ b/sysdeps/unix/opendir.c
@@ -155,9 +155,7 @@ __alloc_dir (int fd, bool close_fd, const struct stat64 *statp)
     allocation = (BUFSIZ < sizeof (struct dirent64)
 		  ? sizeof (struct dirent64) : BUFSIZ);
 
-  const int pad = -sizeof (DIR) % __alignof__ (struct dirent64);
-
-  DIR *dirp = (DIR *) malloc (sizeof (DIR) + allocation + pad);
+  DIR *dirp = (DIR *) malloc (sizeof (DIR) + allocation);
   if (dirp == NULL)
   lose:
     {
@@ -169,14 +167,15 @@ __alloc_dir (int fd, bool close_fd, const struct stat64 *statp)
 	}
       return NULL;
     }
-  memset (dirp, '\0', sizeof (DIR));
-  dirp->data = (char *) (dirp + 1) + pad;
-  dirp->allocation = allocation;
-  dirp->fd = fd;
 
+  dirp->allocation = allocation;
 #ifndef NOT_IN_libc
   __libc_lock_init (dirp->lock);
 #endif
+  dirp->fd = fd;
+  dirp->size = 0;
+  dirp->offset = 0;
+  dirp->filepos = 0;
 
   return dirp;
 }