Skip to content
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

Add optional length to functions accepting const char * #254

Closed
RReverser opened this issue Jun 14, 2017 · 1 comment
Closed

Add optional length to functions accepting const char * #254

RReverser opened this issue Jun 14, 2017 · 1 comment

Comments

@RReverser
Copy link
Member

As discussed in the last meeting, zero-terminated const char*, while popular in C land, might be problematic for consumers in other languages having different string representation (for example, Rust with non-zero-terminated string slices represented as data + length).

Some N-API functions already accept optional length that, when set to -1, would mean a length calculated from zero-terminated string and explicit byte length otherwise.

It's worth to go through a list of functions that accept const char* and add length parameter where it's missing, especially for functions that don't provide variants with napi_value as a string, namely:

  • napi_create_function
  • napi_define_class
  • napi_module_register -> napi_module struct
@digitalinfinity
Copy link
Contributor

Thanks @RReverser - moved discussion to nodejs/node#15108 since this is a nice to have and we'll get more help and visibility on the main repo. Closing this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants