GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — n-api: update reference test · nodejs/node@b26410e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/addons-napi/test_reference
    • test_reference.c
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/addons-napi/test_reference/test_reference.c‎

Copy file name to clipboardExpand all lines: test/addons-napi/test_reference/test_reference.c
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include <node_api.h>
22
#include "../common.h"
3-
#include <stdlib.h>
43

54
static int test_value = 1;
65
static int finalize_count = 0;
@@ -13,7 +12,9 @@ napi_value GetFinalizeCount(napi_env env, napi_callback_info info) {
1312
}
1413

1514
void FinalizeExternal(napi_env env, void* data, void* hint) {
16-
free(data);
15+
int *actual_value = data;
16+
NAPI_ASSERT_RETURN_VOID(env, actual_value == &test_value,
17+
"The correct pointer was passed to the finalizer");
1718
finalize_count++;
1819
}
1920

@@ -33,13 +34,10 @@ napi_value CreateExternal(napi_env env, napi_callback_info info) {
3334
}
3435

3536
napi_value CreateExternalWithFinalize(napi_env env, napi_callback_info info) {
36-
int* data = malloc(sizeof(int));
37-
*data = test_value;
38-
3937
napi_value result;
4038
NAPI_CALL(env,
4139
napi_create_external(env,
42-
data,
40+
&test_value,
4341
FinalizeExternal,
4442
NULL, /* finalize_hint */
4543
&result));

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.