Skip to content

Commit

Permalink
doc: fix n-api example string
Browse files Browse the repository at this point in the history
- using a length of 6 for `"hello"` includes a terminating null yielding
  `"hello\u0000"`
- length of 5 would work,
but comparing to the N-API docs gives `NAPI_AUTO_LENGTH` instead

PR-URL: #19205
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
srl295 authored and BethGriggs committed Dec 3, 2018
1 parent d79e7d6 commit b2fc3b5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion doc/api/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ napi_value Method(napi_env env, napi_callback_info args) {
napi_value greeting;
napi_status status;

status = napi_create_string_utf8(env, "hello", 6, &greeting);
status = napi_create_string_utf8(env, "hello", NAPI_AUTO_LENGTH, &greeting);
if (status != napi_ok) return nullptr;
return greeting;
}
Expand Down

0 comments on commit b2fc3b5

Please sign in to comment.