Skip to content

Commit

Permalink
Add a hard-coded binding to free().
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Sep 20, 2011
1 parent 942a0f0 commit cab1216
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ffi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ void FFI::InitializeBindings(Handle<Object> target)
{
Local<Object> o = Object::New();

target->Set(String::New("free"), FunctionTemplate::New(Free)->GetFunction());
target->Set(String::New("prepCif"), FunctionTemplate::New(FFIPrepCif)->GetFunction());
target->Set(String::New("strtoul"), FunctionTemplate::New(Strtoul)->GetFunction());
target->Set(String::New("POINTER_SIZE"), Integer::New(sizeof(unsigned char *)));
Expand Down Expand Up @@ -101,6 +102,14 @@ void FFI::InitializeBindings(Handle<Object> target)
target->Set(String::New("TYPE_SIZE_MAP"), smap);
}

Handle<Value> FFI::Free(const Arguments &args)
{
HandleScope scope;
Pointer *p = ObjectWrap::Unwrap<Pointer>(args[0]->ToObject());
free(p->GetPointer());
return Undefined();
}

Handle<Value> FFI::Strtoul(const Arguments &args)
{
HandleScope scope;
Expand Down
1 change: 1 addition & 0 deletions src/ffi.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class FFI : public ObjectWrap {
static void InitializeBindings(Handle<Object> Target);

protected:
static Handle<Value> Free(const Arguments& args);
static Handle<Value> FFIPrepCif(const Arguments& args);
static Handle<Value> Strtoul(const Arguments& args);
};
Expand Down

0 comments on commit cab1216

Please sign in to comment.