You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Buffer data argument should be void*, not char* #135
As I mentioned in another issue, it is arguably a historical oversight that node::Buffer takes a char* as the data argument and not a void*. This leads to mandatory typecasting whenever something else than a char* is given to node::Buffer. Now is a good chance not to repeat the same mistake.
NODE_EXTERN napi_status napi_create_buffer(napi_env e,
size_t size,
void** data,
napi_value* result);
NODE_EXTERN napi_status napi_create_external_buffer(napi_env e,
size_t size,
void* data,
napi_finalize finalize_cb,
napi_value* result);
NODE_EXTERN napi_status napi_create_buffer_copy(napi_env e,
constvoid* data,
size_t size,
napi_value* result);
NODE_EXTERN napi_status napi_is_buffer(napi_env e, napi_value v, bool* result);
NODE_EXTERN napi_status napi_get_buffer_info(napi_env e,
napi_value v,
void** data,
size_t* length);
Additionally, the C++ layer could use a class template parametrized on the type of data to ensure further type safety.
Activity
boingoing commentedon Mar 16, 2017
Resolved by #145