mirror of
https://github.com/nodejs/node.git
synced 2025-05-22 00:43:56 +00:00

* Prefix functions with `static` to make them local * Remove anonymous namespaces * `nullptr` -> `NULL` * .cc -> .c and update binding.gyp * `static_cast<x>()` -> `(x)()` * Replace `new`/`delete` with `malloc()`/`free()` (only in test_callback_scope) * Move lambda out and convert to local function (only in test_callback_scope) * Remove superfluous `#include <vector>` (only in test_callback_scope_recurse) Some tests are best left as C++. ```bash ls -l test/{node-api,js-native-api}/*/*.cc ``` for those remaining as C++ tests. Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com> PR-URL: https://github.com/nodejs/node/pull/34615 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
21 lines
500 B
C
21 lines
500 B
C
#include "node_api.h"
|
|
#include "uv.h"
|
|
#include "../../js-native-api/common.h"
|
|
|
|
static void cleanup(void* arg) {
|
|
printf("cleanup(%d)\n", *(int*)(arg));
|
|
}
|
|
|
|
static int secret = 42;
|
|
static int wrong_secret = 17;
|
|
|
|
static napi_value Init(napi_env env, napi_value exports) {
|
|
napi_add_env_cleanup_hook(env, cleanup, &wrong_secret);
|
|
napi_add_env_cleanup_hook(env, cleanup, &secret);
|
|
napi_remove_env_cleanup_hook(env, cleanup, &wrong_secret);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)
|