forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinding.cc
More file actions
30 lines (24 loc) · 860 Bytes
/
binding.cc
File metadata and controls
30 lines (24 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <node.h>
#include <smalloc.h>
#include <v8.h>
using namespace v8;
void Alloc(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
Local<Object> obj = Object::New(isolate);
size_t len = args[0]->Uint32Value();
node::smalloc::Alloc(isolate, obj, len);
args.GetReturnValue().Set(obj);
}
void Dispose(const FunctionCallbackInfo<Value>& args) {
node::smalloc::AllocDispose(args.GetIsolate(), args[0].As<Object>());
}
void HasExternalData(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(
node::smalloc::HasExternalData(args.GetIsolate(), args[0].As<Object>()));
}
void init(Handle<Object> target) {
NODE_SET_METHOD(target, "alloc", Alloc);
NODE_SET_METHOD(target, "dispose", Dispose);
NODE_SET_METHOD(target, "hasExternalData", HasExternalData);
}
NODE_MODULE(binding, init);