summaryrefslogtreecommitdiff
path: root/libc/misc/dirent/opendir.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-11-14 11:09:46 +0000
committerEric Andersen <andersen@codepoet.org>2001-11-14 11:09:46 +0000
commit62653059d61eae9c559b514bb126df9e2e845273 (patch)
treea295a9292cd4d22e4932e0054afd83cb268fbf15 /libc/misc/dirent/opendir.c
parenta5cc55111f77315fc7e04613772237b52a3dbfdf (diff)
Scrub up some lingering problems preventing readdir64 from working
and creating several *64 problems, particualrly when client apps used -D_FILE_OFFSET_BITS=64 -D__USE_FILE_OFFSET64. All better now. -Erik
Diffstat (limited to 'libc/misc/dirent/opendir.c')
-rw-r--r--libc/misc/dirent/opendir.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libc/misc/dirent/opendir.c b/libc/misc/dirent/opendir.c
index 25b5873e1..e2a6000ca 100644
--- a/libc/misc/dirent/opendir.c
+++ b/libc/misc/dirent/opendir.c
@@ -37,19 +37,20 @@ DIR *opendir(const char *name)
return NULL;
}
+ ptr->dd_fd = fd;
+ ptr->dd_nextloc = ptr->dd_size = ptr->dd_nextoff = 0;
+ ptr->dd_getdents = unknown;
+
ptr->dd_max = statbuf.st_blksize;
if (ptr->dd_max < 512)
ptr->dd_max = 512;
- if (!(buf = malloc(ptr->dd_max))) {
+ if (!(buf = calloc(1, ptr->dd_max))) {
close(fd);
free(ptr);
__set_errno(ENOMEM);
return NULL;
}
- ptr->dd_fd = fd;
- ptr->dd_nextoff = ptr->dd_nextloc = ptr->dd_size = 0;
ptr->dd_buf = buf;
- ptr->dd_getdents = unknown;
return ptr;
}