From e78522de945449220ed3ff9b4c0249b0e9465cd0 Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Sun, 20 Nov 2022 01:31:36 +0800 Subject: [PATCH] node-api: declare type napi_cleanup_hook Declare type `napi_cleanup_hook` so that the function signature can be shared across the codebase. PR-URL: https://github.com/nodejs/node/pull/45391 Reviewed-By: Michael Dawson Reviewed-By: Daeyeon Jeong --- doc/api/n-api.md | 20 +++++++++++++++++++- src/node_api.cc | 10 ++++++---- src/node_api.h | 8 ++++---- src/node_api_types.h | 5 +++++ 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 1c43a878683317..7d6336ff7472fc 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -898,6 +898,24 @@ typedef void (*napi_threadsafe_function_call_js)(napi_env env, Unless for reasons discussed in [Object Lifetime Management][], creating a handle and/or callback scope inside the function body is not necessary. +#### `napi_cleanup_hook` + + + +Function pointer used with [`napi_add_env_cleanup_hook`][]. It will be called +when the environment is being torn down. + +Callback functions must satisfy the following signature: + +```c +typedef void (*napi_cleanup_hook)(void* data); +``` + +* `[in] data`: The data that was passed to [`napi_add_env_cleanup_hook`][]. + #### `napi_async_cleanup_hook`