n-api: add optional string length parameter#15343
n-api: add optional string length parameter#15343sampsongao wants to merge 10 commits intonodejs:masterfrom
Conversation
|
We need new test cases that verify the behavior of each of these APIs with lengths other than -1. For each API a test should pass in a longer string value and then check that the result is truncated according to the length. |
5f8d256 to
d9cab83
Compare
d9cab83 to
cf0f4fa
Compare
|
There seem to be ci failures on BSD: https://ci.nodejs.org/job/node-test-commit-freebsd/11584/nodes=freebsd10-64/console |
| ```C | ||
| NAPI_NO_RETURN void napi_fatal_error(const char* location, const char* message); | ||
| NAPI_EXTERN NAPI_NO_RETURN void napi_fatal_error(const char* location, | ||
| size_t location_len, |
There was a problem hiding this comment.
Should NAPI_EXTERN be added here ?
src/node_api.cc
Outdated
| char* location_string = const_cast<char*>(location); | ||
| char* message_string = const_cast<char*>(message); | ||
| if (location_len != -1) { | ||
| location_string = (char*) malloc(location_len * sizeof(char) + 1); |
There was a problem hiding this comment.
I thought we were going to use stack allocation, won't the malloc's result in a memory leak ?
There was a problem hiding this comment.
@sampsongao pointed out that the process will terminate when we call napi_fatal_error so it should be ok.
|
Still failures on freebsd |
225289d to
b0175ae
Compare
|
CI looks good except for linter failure. I believe that was a problem either in CI or in master as the previous few linter jobs failed in the same way. |
|
Seems like lint issue was not ci related: |
6bd811d to
cffe74e
Compare
cffe74e to
8e7bf47
Compare
|
Another CI run: https://ci.nodejs.org/job/node-test-pull-request/10126/ |
|
Arm failure was: nodejs/build#884 |
|
CI was good going to land. |
PR-URL: #15343 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
|
Landed as 1976654 |
PR-URL: #15343 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
PR-URL: nodejs/node#15343 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
PR-URL: nodejs/node#15343 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
PR-URL: nodejs#15343 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)