ext/libuv/src/unix/fs.c in libuv-1.2.0 vs ext/libuv/src/unix/fs.c in libuv-1.3.0

- old
+ new

@@ -83,11 +83,11 @@ do { \ size_t path_len; \ size_t new_path_len; \ path_len = strlen((path)) + 1; \ new_path_len = strlen((new_path)) + 1; \ - (req)->path = malloc(path_len + new_path_len); \ + (req)->path = uv__malloc(path_len + new_path_len); \ if ((req)->path == NULL) \ return -ENOMEM; \ (req)->new_path = (req)->path + path_len; \ memcpy((void*) (req)->path, (path), path_len); \ memcpy((void*) (req)->new_path, (new_path), new_path_len); \ @@ -270,11 +270,11 @@ #endif } done: if (req->bufs != req->bufsml) - free(req->bufs); + uv__free(req->bufs); return result; } #if defined(__OpenBSD__) || (defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_8)) @@ -310,12 +310,12 @@ saved_errno = errno; if (dents != NULL) { int i; for (i = 0; i < n; i++) - free(dents[i]); - free(dents); + uv__free(dents[i]); + uv__free(dents); } errno = saved_errno; req->ptr = NULL; @@ -335,21 +335,21 @@ #else len = 4096; #endif } - buf = malloc(len + 1); + buf = uv__malloc(len + 1); if (buf == NULL) { errno = ENOMEM; return -1; } len = readlink(req->path, buf, len); if (len == -1) { - free(buf); + uv__free(buf); return -1; } buf[len] = '\0'; req->ptr = buf; @@ -631,11 +631,11 @@ #if defined(__APPLE__) pthread_mutex_unlock(&lock); #endif if (req->bufs != req->bufsml) - free(req->bufs); + uv__free(req->bufs); return r; } static void uv__to_stat(struct stat* src, uv_stat_t* dst) { @@ -659,12 +659,26 @@ dst->st_ctim.tv_nsec = src->st_ctimespec.tv_nsec; dst->st_birthtim.tv_sec = src->st_birthtimespec.tv_sec; dst->st_birthtim.tv_nsec = src->st_birthtimespec.tv_nsec; dst->st_flags = src->st_flags; dst->st_gen = src->st_gen; -#elif !defined(_AIX) && \ - (defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || defined(_XOPEN_SOURCE)) +#elif defined(__ANDROID__) + dst->st_atim.tv_sec = src->st_atime; + dst->st_atim.tv_nsec = src->st_atime_nsec; + dst->st_mtim.tv_sec = src->st_mtime; + dst->st_mtim.tv_nsec = src->st_mtime_nsec; + dst->st_ctim.tv_sec = src->st_ctime; + dst->st_ctim.tv_nsec = src->st_ctime_nsec; + dst->st_birthtim.tv_sec = src->st_ctime; + dst->st_birthtim.tv_nsec = src->st_ctime_nsec; + dst->st_flags = 0; + dst->st_gen = 0; +#elif !defined(_AIX) && ( \ + defined(_BSD_SOURCE) || \ + defined(_SVID_SOURCE) || \ + defined(_XOPEN_SOURCE) || \ + defined(_DEFAULT_SOURCE)) dst->st_atim.tv_sec = src->st_atim.tv_sec; dst->st_atim.tv_nsec = src->st_atim.tv_nsec; dst->st_mtim.tv_sec = src->st_mtim.tv_sec; dst->st_mtim.tv_nsec = src->st_mtim.tv_nsec; dst->st_ctim.tv_sec = src->st_ctim.tv_sec; @@ -1020,11 +1034,11 @@ req->file = file; req->nbufs = nbufs; req->bufs = req->bufsml; if (nbufs > ARRAY_SIZE(req->bufsml)) - req->bufs = malloc(nbufs * sizeof(*bufs)); + req->bufs = uv__malloc(nbufs * sizeof(*bufs)); if (req->bufs == NULL) return -ENOMEM; memcpy(req->bufs, bufs, nbufs * sizeof(*bufs)); @@ -1142,11 +1156,11 @@ req->file = file; req->nbufs = nbufs; req->bufs = req->bufsml; if (nbufs > ARRAY_SIZE(req->bufsml)) - req->bufs = malloc(nbufs * sizeof(*bufs)); + req->bufs = uv__malloc(nbufs * sizeof(*bufs)); if (req->bufs == NULL) return -ENOMEM; memcpy(req->bufs, bufs, nbufs * sizeof(*bufs)); @@ -1155,16 +1169,16 @@ POST; } void uv_fs_req_cleanup(uv_fs_t* req) { - free((void*) req->path); + uv__free((void*)req->path); req->path = NULL; req->new_path = NULL; if (req->fs_type == UV_FS_SCANDIR && req->ptr != NULL) uv__fs_scandir_cleanup(req); if (req->ptr != &req->statbuf) - free(req->ptr); + uv__free(req->ptr); req->ptr = NULL; }