Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
doc: add note regarding insufficient buffer size
  • Loading branch information
taveras committed Aug 18, 2017
commit 139229255e07e3cedac53dae5d209abf23b50d89
4 changes: 2 additions & 2 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1837,8 +1837,8 @@ napi_status napi_get_value_string_utf8(napi_env env,
- `[in] env`: The environment that the API is invoked under.
- `[in] value`: `napi_value` representing JavaScript string.
- `[in] buf`: Buffer to write the UTF8-encoded string into. If NULL is passed
in, the length of the string (in bytes) is returned.
- `[in] bufsize`: Size of the destination buffer.
in, the length of the string (in bytes) is returned.
- `[in] bufsize`: Size of the destination buffer. When this value is insufficient, the returned string will be truncated.
- `[out] result`: Number of bytes copied into the buffer, excluding the null
terminator.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the buffer size is insufficient, the string will be truncated including a null terminator.

I feel like this information should be represented somewhere, maybe as part of the bufsize parameter?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ah, yes! do you feel it may be best to keep this sentence within the [out] result description?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be better to move that sentence to be part of the [in] bufsize parameter comment. That's where it's relevant to call out that the string will be truncated, but still include a null terminator.


Expand Down