summaryrefslogtreecommitdiff
path: root/deps/uv/src/unix/fs.c
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2014-09-19 21:37:55 +0400
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-09-23 08:18:41 -0700
commitc5f5d4cd11c2aec74fa03985405122d1ecb06f69 (patch)
tree17accc5b501eb89e6810cac8df50b54901b6cfee /deps/uv/src/unix/fs.c
parent6e08bb94e8b1aaf913cf88106cb59f9d2ae85925 (diff)
downloadandroid-node-v8-c5f5d4cd11c2aec74fa03985405122d1ecb06f69.tar.gz
android-node-v8-c5f5d4cd11c2aec74fa03985405122d1ecb06f69.tar.bz2
android-node-v8-c5f5d4cd11c2aec74fa03985405122d1ecb06f69.zip
deps: update uv to v1.0.0-rc1
Diffstat (limited to 'deps/uv/src/unix/fs.c')
-rw-r--r--deps/uv/src/unix/fs.c41
1 files changed, 12 insertions, 29 deletions
diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c
index 47f667229d..2dd0fe97cc 100644
--- a/deps/uv/src/unix/fs.c
+++ b/deps/uv/src/unix/fs.c
@@ -38,7 +38,6 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <pthread.h>
-#include <dirent.h>
#include <unistd.h>
#include <fcntl.h>
#include <utime.h>
@@ -296,9 +295,9 @@ done:
#if defined(__OpenBSD__) || (defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_8))
-static int uv__fs_readdir_filter(struct dirent* dent) {
+static int uv__fs_readdir_filter(uv__dirent_t* dent) {
#else
-static int uv__fs_readdir_filter(const struct dirent* dent) {
+static int uv__fs_readdir_filter(const uv__dirent_t* dent) {
#endif
return strcmp(dent->d_name, ".") != 0 && strcmp(dent->d_name, "..") != 0;
}
@@ -306,12 +305,8 @@ static int uv__fs_readdir_filter(const struct dirent* dent) {
/* This should have been called uv__fs_scandir(). */
static ssize_t uv__fs_readdir(uv_fs_t* req) {
- struct dirent **dents;
+ uv__dirent_t **dents;
int saved_errno;
- size_t off;
- size_t len;
- char *buf;
- int i;
int n;
dents = NULL;
@@ -322,32 +317,17 @@ static ssize_t uv__fs_readdir(uv_fs_t* req) {
else if (n == -1)
return n;
- len = 0;
-
- for (i = 0; i < n; i++)
- len += strlen(dents[i]->d_name) + 1;
-
- buf = malloc(len);
-
- if (buf == NULL) {
- errno = ENOMEM;
- n = -1;
- goto out;
- }
-
- off = 0;
-
- for (i = 0; i < n; i++) {
- len = strlen(dents[i]->d_name) + 1;
- memcpy(buf + off, dents[i]->d_name, len);
- off += len;
- }
+ /* NOTE: We will use nbufs as an index field */
+ req->ptr = dents;
+ req->nbufs = 0;
- req->ptr = buf;
+ return n;
out:
saved_errno = errno;
if (dents != NULL) {
+ int i;
+
for (i = 0; i < n; i++)
free(dents[i]);
free(dents);
@@ -1184,6 +1164,9 @@ void uv_fs_req_cleanup(uv_fs_t* req) {
req->path = NULL;
req->new_path = NULL;
+ if (req->fs_type == UV_FS_READDIR && req->ptr != NULL)
+ uv__fs_readdir_cleanup(req);
+
if (req->ptr != &req->statbuf)
free(req->ptr);
req->ptr = NULL;