@@ -2386,7 +2386,7 @@ int SSLWrap<Base>::TLSExtStatusCallback(SSL* s, void* arg) {
2386
2386
size_t len = Buffer::Length (obj);
2387
2387
2388
2388
// OpenSSL takes control of the pointer after accepting it
2389
- char * data = reinterpret_cast < char *>( node::Malloc (len) );
2389
+ char * data = node::Malloc (len);
2390
2390
CHECK_NE (data, nullptr );
2391
2391
memcpy (data, resp, len);
2392
2392
@@ -3466,7 +3466,7 @@ bool CipherBase::GetAuthTag(char** out, unsigned int* out_len) const {
3466
3466
if (initialised_ || kind_ != kCipher || !auth_tag_)
3467
3467
return false ;
3468
3468
*out_len = auth_tag_len_;
3469
- *out = static_cast < char *>( node::Malloc (auth_tag_len_) );
3469
+ *out = node::Malloc (auth_tag_len_);
3470
3470
CHECK_NE (*out, nullptr );
3471
3471
memcpy (*out, auth_tag_, auth_tag_len_);
3472
3472
return true ;
@@ -5138,7 +5138,7 @@ void ECDH::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
5138
5138
// NOTE: field_size is in bits
5139
5139
int field_size = EC_GROUP_get_degree (ecdh->group_ );
5140
5140
size_t out_len = (field_size + 7 ) / 8 ;
5141
- char * out = static_cast < char *>( node::Malloc (out_len) );
5141
+ char * out = node::Malloc (out_len);
5142
5142
CHECK_NE (out, nullptr );
5143
5143
5144
5144
int r = ECDH_compute_key (out, out_len, pub, ecdh->key_ , nullptr );
@@ -5174,7 +5174,7 @@ void ECDH::GetPublicKey(const FunctionCallbackInfo<Value>& args) {
5174
5174
if (size == 0 )
5175
5175
return env->ThrowError (" Failed to get public key length" );
5176
5176
5177
- unsigned char * out = static_cast <unsigned char *>( node::Malloc ( size) );
5177
+ unsigned char * out = node::Malloc <unsigned char >( size);
5178
5178
CHECK_NE (out, nullptr );
5179
5179
5180
5180
int r = EC_POINT_point2oct (ecdh->group_ , pub, form, out, size, nullptr );
@@ -5200,7 +5200,7 @@ void ECDH::GetPrivateKey(const FunctionCallbackInfo<Value>& args) {
5200
5200
return env->ThrowError (" Failed to get ECDH private key" );
5201
5201
5202
5202
int size = BN_num_bytes (b);
5203
- unsigned char * out = static_cast <unsigned char *>( node::Malloc ( size) );
5203
+ unsigned char * out = node::Malloc <unsigned char >( size);
5204
5204
CHECK_NE (out, nullptr );
5205
5205
5206
5206
if (size != BN_bn2bin (b, out)) {
@@ -5333,7 +5333,7 @@ class PBKDF2Request : public AsyncWrap {
5333
5333
saltlen_(saltlen),
5334
5334
salt_(salt),
5335
5335
keylen_(keylen),
5336
- key_(static_cast < char *>( node::Malloc(keylen) )),
5336
+ key_(node::Malloc(keylen)),
5337
5337
iter_(iter) {
5338
5338
if (key () == nullptr )
5339
5339
FatalError (" node::PBKDF2Request()" , " Out of Memory" );
@@ -5496,7 +5496,7 @@ void PBKDF2(const FunctionCallbackInfo<Value>& args) {
5496
5496
5497
5497
THROW_AND_RETURN_IF_NOT_BUFFER (args[1 ], " Salt" );
5498
5498
5499
- pass = static_cast < char *>( node::Malloc (passlen) );
5499
+ pass = node::Malloc (passlen);
5500
5500
if (pass == nullptr ) {
5501
5501
FatalError (" node::PBKDF2()" , " Out of Memory" );
5502
5502
}
@@ -5508,7 +5508,7 @@ void PBKDF2(const FunctionCallbackInfo<Value>& args) {
5508
5508
goto err;
5509
5509
}
5510
5510
5511
- salt = static_cast < char *>( node::Malloc (saltlen) );
5511
+ salt = node::Malloc (saltlen);
5512
5512
if (salt == nullptr ) {
5513
5513
FatalError (" node::PBKDF2()" , " Out of Memory" );
5514
5514
}
@@ -5601,7 +5601,7 @@ class RandomBytesRequest : public AsyncWrap {
5601
5601
: AsyncWrap(env, object, AsyncWrap::PROVIDER_CRYPTO),
5602
5602
error_ (0 ),
5603
5603
size_(size),
5604
- data_(static_cast < char *>( node::Malloc(size) )) {
5604
+ data_(node::Malloc(size)) {
5605
5605
if (data () == nullptr )
5606
5606
FatalError (" node::RandomBytesRequest()" , " Out of Memory" );
5607
5607
Wrap (object, this );
@@ -5828,8 +5828,7 @@ void GetCurves(const FunctionCallbackInfo<Value>& args) {
5828
5828
EC_builtin_curve* curves;
5829
5829
5830
5830
if (num_curves) {
5831
- curves = static_cast <EC_builtin_curve*>(node::Malloc (sizeof (*curves),
5832
- num_curves));
5831
+ curves = node::Malloc<EC_builtin_curve>(num_curves);
5833
5832
5834
5833
CHECK_NE (curves, nullptr );
5835
5834
0 commit comments