• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "node_api.h"
2 #include "uv.h"
3 #include "../../js-native-api/common.h"
4 
5 namespace {
6 
cleanup(void * arg)7 void cleanup(void* arg) {
8   printf("cleanup(%d)\n", *static_cast<int*>(arg));
9 }
10 
11 int secret = 42;
12 int wrong_secret = 17;
13 
Init(napi_env env,napi_value exports)14 napi_value Init(napi_env env, napi_value exports) {
15   napi_add_env_cleanup_hook(env, cleanup, &wrong_secret);
16   napi_add_env_cleanup_hook(env, cleanup, &secret);
17   napi_remove_env_cleanup_hook(env, cleanup, &wrong_secret);
18 
19   return nullptr;
20 }
21 
22 }  // anonymous namespace
23 
24 NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)
25