src: move ReqWrap::data_ to FSReqWrap
authorBen Noordhuis <info@bnoordhuis.nl>
Tue, 13 Aug 2013 09:56:44 +0000 (11:56 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Tue, 13 Aug 2013 09:56:45 +0000 (11:56 +0200)
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
src/req_wrap.h

index e01c5bd..856661f 100644 (file)
@@ -64,12 +64,14 @@ using v8::Value;
 class FSReqWrap: public ReqWrap<uv_fs_t> {
  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<char*>(req_wrap->data_);
+    delete[] req_wrap->data_;
 
   // there is always at least one argument. "error"
   int argc = 1;
index 1187df9..44749a3 100644 (file)
@@ -74,7 +74,6 @@ class ReqWrap {
 
   v8::Persistent<v8::Object> object_;
   QUEUE req_wrap_queue_;
-  void* data_;
   T req_;  // *must* be last, GetActiveRequests() in node.cc depends on it
 };