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

Merged

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.

@vmoroz
Copy link
Member

vmoroz commented May 11, 2025

@tniessen , we discussed this PR in out last Node-API meeting on 5/9/2025.
The team advised me to provide the text change suggestions instead of the general comment.

Co-authored-by: Vladimir Morozov <[email protected]>
@tniessen tniessen added the commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. label May 12, 2025
Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@legendecas legendecas added the commit-queue Add this label to land a pull request using GitHub Actions. label May 12, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 12, 2025
@nodejs-github-bot nodejs-github-bot merged commit acb3d92 into nodejs:main May 12, 2025
22 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in acb3d92

@github-project-automation github-project-automation bot moved this from Need Triage to Done in Node-API Team Project May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. doc Issues and PRs related to the documentations. node-api Issues and PRs related to the Node-API.
Projects
Development

Successfully merging this pull request may close these issues.

8 participants