From 43b8a9122da9852b14b8af22d7fab79fb45d9332 Mon Sep 17 00:00:00 2001 From: legendecas Date: Thu, 10 Nov 2022 00:48:35 +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. --- 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 3a2b9bceb2ab64..2fef1b5bfe55a5 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -897,6 +897,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`