Permalink
Browse files

Fix UVData::ObjectTo<T>

  • Loading branch information...
1 parent c883dc6 commit 1e8941e5996eae85ed3a77171d3b888c09b7251f @creationix creationix committed Mar 22, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/luv.cc
View
11 src/luv.cc
@@ -3,7 +3,7 @@
#include "candor.h"
#include "uv.h"
-#include <stdlib.h>
+#include <stdio.h>
using namespace candor;
@@ -23,21 +23,24 @@ UVData::UVData(size_t size, Object* prototype) {
obj.Unref();
// Create a uv structure
- handle = (uv_handle_t*)malloc(size);
+ handle = (uv_handle_t*)new char[size];
+ printf("uv_handle_t* %p\n", handle);
// And point it to us too.
handle->data = &obj;
}
UVData::~UVData() {
// Free the uv struct
- free(handle);
+ delete handle;
// Let go of the data object
obj.Unwrap();
}
template <class T>
T* UVData::ObjectTo(candor::Object* obj) {
- return (T*)((UVData*)obj->Get("cdata")->As<CData>()->GetContents())->handle;
+ uv_handle_t* handle = CWrapper::Unwrap<UVData>(obj->Get("cdata"))->handle;
+ printf("handle %p\n", handle);
+ return (T*)handle;
}
Object* UVData::VoidToObject(void* ptr) {

0 comments on commit 1e8941e

Please sign in to comment.