#include #include #include void EnsureAllocation(const v8::FunctionCallbackInfo &args) { v8::Isolate* isolate = args.GetIsolate(); uintptr_t size = args[0]->IntegerValue(); v8::Local success; void* buffer = malloc(size); if (buffer) { success = v8::Boolean::New(isolate, true); free(buffer); } else { success = v8::Boolean::New(isolate, false); } args.GetReturnValue().Set(success); } void init(v8::Local exports) { NODE_SET_METHOD(exports, "ensureAllocation", EnsureAllocation); } NODE_MODULE(NODE_GYP_MODULE_NAME, init)