Use ForeignType::into_ptr wherever applicable

This commit is contained in:
Rushil Mehra 2024-09-03 08:04:30 -07:00 committed by Rushil Mehra
parent e5b6627efc
commit 7324db2b75
3 changed files with 8 additions and 14 deletions

View File

@ -280,8 +280,7 @@ impl Dsa<Public> {
let dsa = Dsa::from_ptr(cvt_p(ffi::DSA_new())?); let dsa = Dsa::from_ptr(cvt_p(ffi::DSA_new())?);
cvt(DSA_set0_pqg(dsa.0, p.as_ptr(), q.as_ptr(), g.as_ptr()))?; cvt(DSA_set0_pqg(dsa.0, p.as_ptr(), q.as_ptr(), g.as_ptr()))?;
mem::forget((p, q, g)); mem::forget((p, q, g));
cvt(DSA_set0_key(dsa.0, pub_key.as_ptr(), ptr::null_mut()))?; cvt(DSA_set0_key(dsa.0, pub_key.into_ptr(), ptr::null_mut()))?;
mem::forget(pub_key);
Ok(dsa) Ok(dsa)
} }
} }

View File

@ -1068,9 +1068,9 @@ impl SslContextBuilder {
assert!(!self.is_rpk, "This API is not supported for RPK"); assert!(!self.is_rpk, "This API is not supported for RPK");
unsafe { unsafe {
let ptr = cert_store.as_ptr(); cvt(
cvt(ffi::SSL_CTX_set0_verify_cert_store(self.as_ptr(), ptr) as c_int)?; ffi::SSL_CTX_set0_verify_cert_store(self.as_ptr(), cert_store.into_ptr()) as c_int,
mem::forget(cert_store); )?;
Ok(()) Ok(())
} }
@ -1083,8 +1083,7 @@ impl SslContextBuilder {
assert!(!self.is_rpk, "This API is not supported for RPK"); assert!(!self.is_rpk, "This API is not supported for RPK");
unsafe { unsafe {
ffi::SSL_CTX_set_cert_store(self.as_ptr(), cert_store.as_ptr()); ffi::SSL_CTX_set_cert_store(self.as_ptr(), cert_store.into_ptr());
mem::forget(cert_store);
} }
} }
@ -1260,8 +1259,7 @@ impl SslContextBuilder {
assert!(!self.is_rpk, "This API is not supported for RPK"); assert!(!self.is_rpk, "This API is not supported for RPK");
unsafe { unsafe {
cvt(ffi::SSL_CTX_add_extra_chain_cert(self.as_ptr(), cert.as_ptr()) as c_int)?; cvt(ffi::SSL_CTX_add_extra_chain_cert(self.as_ptr(), cert.into_ptr()) as c_int)?;
mem::forget(cert);
Ok(()) Ok(())
} }
} }
@ -2742,8 +2740,7 @@ impl SslRef {
); );
unsafe { unsafe {
cvt(ffi::SSL_set0_verify_cert_store(self.as_ptr(), cert_store.as_ptr()) as c_int)?; cvt(ffi::SSL_set0_verify_cert_store(self.as_ptr(), cert_store.into_ptr()) as c_int)?;
mem::forget(cert_store);
Ok(()) Ok(())
} }
} }

View File

@ -1584,9 +1584,7 @@ impl GeneralName {
ffi::init(); ffi::init();
let gn = cvt_p(ffi::GENERAL_NAME_new())?; let gn = cvt_p(ffi::GENERAL_NAME_new())?;
(*gn).type_ = ffi::GEN_RID; (*gn).type_ = ffi::GEN_RID;
(*gn).d.registeredID = oid.as_ptr(); (*gn).d.registeredID = oid.into_ptr();
mem::forget(oid);
Ok(GeneralName::from_ptr(gn)) Ok(GeneralName::from_ptr(gn))
} }