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