From 581b38af1355e2036ac3f0067e9fd02234d86d95 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 3a090344fc92c8..8689f6bf90f5c1 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`