mirror of
https://github.com/nodejs/node.git
synced 2024-11-25 08:19:38 +01:00
78286984da
Currently the nm_modname does not match the file name of the resulting module. In fact, the nm_modname is pretty arbitrary. This seeks to introduce some consistency into the nm_modname property by having the name of the module appear in exactly one place: the "target_name" property of the gyp target that builds the module. PR-URL: https://github.com/nodejs/node/pull/15209 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
42 lines
831 B
C++
42 lines
831 B
C++
#include <node.h>
|
|
#include <node_buffer.h>
|
|
#include <v8.h>
|
|
|
|
#include <assert.h>
|
|
|
|
static int alive;
|
|
|
|
static void FreeCallback(char* data, void* hint) {
|
|
assert(data == nullptr);
|
|
alive--;
|
|
}
|
|
|
|
void Run(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|
v8::Isolate* isolate = args.GetIsolate();
|
|
alive++;
|
|
|
|
{
|
|
v8::HandleScope scope(isolate);
|
|
v8::Local<v8::Object> buf = node::Buffer::New(
|
|
isolate,
|
|
nullptr,
|
|
0,
|
|
FreeCallback,
|
|
nullptr).ToLocalChecked();
|
|
|
|
char* data = node::Buffer::Data(buf);
|
|
assert(data == nullptr);
|
|
}
|
|
|
|
isolate->RequestGarbageCollectionForTesting(
|
|
v8::Isolate::kFullGarbageCollection);
|
|
|
|
assert(alive == 0);
|
|
}
|
|
|
|
void init(v8::Local<v8::Object> exports) {
|
|
NODE_SET_METHOD(exports, "run", Run);
|
|
}
|
|
|
|
NODE_MODULE(NODE_GYP_MODULE_NAME, init)
|