From ffc5d83568cc9ff694c6461aaa9dfc70545bf23c Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 13 Aug 2013 11:56:44 +0200 Subject: [PATCH] src: move ReqWrap::data_ to FSReqWrap FSReqWrap is the only ReqWrap child class that uses the data_ field so move it out of ReqWrap and into FSReqWrap. --- src/node_file.cc | 8 +++++--- src/req_wrap.h | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index e01c5bd678a..856661f7c4d 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -64,12 +64,14 @@ using v8::Value; class FSReqWrap: public ReqWrap { public: explicit FSReqWrap(const char* syscall) - : must_free_(false), - syscall_(syscall) { + : must_free_(false) + , data_(NULL) + , syscall_(syscall) { } const char* syscall() { return syscall_; } bool must_free_; // request is responsible for free'ing memory oncomplete + char* data_; private: const char* syscall_; @@ -103,7 +105,7 @@ static void After(uv_fs_t *req) { // check if data needs to be cleaned if (req_wrap->must_free_ == true) - delete[] static_cast(req_wrap->data_); + delete[] req_wrap->data_; // there is always at least one argument. "error" int argc = 1; diff --git a/src/req_wrap.h b/src/req_wrap.h index 1187df9ce0e..44749a3004e 100644 --- a/src/req_wrap.h +++ b/src/req_wrap.h @@ -74,7 +74,6 @@ class ReqWrap { v8::Persistent object_; QUEUE req_wrap_queue_; - void* data_; T req_; // *must* be last, GetActiveRequests() in node.cc depends on it };