Skip to content

doc: clarify napi_get_value_string_* for bufsize 0 #58158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tniessen
Copy link
Member

@tniessen tniessen commented May 4, 2025

This edge case is ambiguous and it is unclear from the existing documentation what happens in this case.

@tniessen tniessen added doc Issues and PRs related to the documentations. node-api Issues and PRs related to the Node-API. labels May 4, 2025
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/node-api

@vmoroz
Copy link
Member

vmoroz commented May 4, 2025

I would rather change it to say that if bufsize is zero and the buf pointer is not null, then the string is not returned and not measured.
To me the phrase "null-terminated if possible" sounds a bit ambiguous.
We do always null-terminate string when we return it. We obviously cannot null terminate it when we do not return it.
We do not return the string when either buf is null or the bufsize is zero.
The buffer size must be big enough to fit the string and its null terminator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. node-api Issues and PRs related to the Node-API.
Projects
Status: Need Triage
Development

Successfully merging this pull request may close these issues.

4 participants