stop explicitly casting references to rawptrs
This commit is contained in:
parent
37049d743e
commit
0ec8fab82c
|
@ -661,7 +661,7 @@ impl<T> CPtr for [T] {
|
|||
|
||||
fn as_mut_c_ptr(&mut self) -> *mut Self::Target {
|
||||
if self.is_empty() {
|
||||
ptr::null::<Self::Target>() as *mut _
|
||||
ptr::null_mut::<Self::Target>()
|
||||
} else {
|
||||
self.as_mut_ptr()
|
||||
}
|
||||
|
|
12
src/key.rs
12
src/key.rs
|
@ -219,13 +219,13 @@ impl PublicKey {
|
|||
/// Obtains a raw const pointer suitable for use with FFI functions
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const ffi::PublicKey {
|
||||
&self.0 as *const _
|
||||
&self.0
|
||||
}
|
||||
|
||||
/// Obtains a raw mutable pointer suitable for use with FFI functions
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&mut self) -> *mut ffi::PublicKey {
|
||||
&mut self.0 as *mut _
|
||||
&mut self.0
|
||||
}
|
||||
|
||||
/// Creates a new public key from a secret key.
|
||||
|
@ -313,7 +313,7 @@ impl PublicKey {
|
|||
secp: &Secp256k1<C>
|
||||
) {
|
||||
unsafe {
|
||||
let res = ffi::secp256k1_ec_pubkey_negate(secp.ctx, &mut self.0 as *mut _);
|
||||
let res = ffi::secp256k1_ec_pubkey_negate(secp.ctx, &mut self.0);
|
||||
debug_assert_eq!(res, 1);
|
||||
}
|
||||
}
|
||||
|
@ -331,8 +331,7 @@ impl PublicKey {
|
|||
return Err(Error::InvalidTweak);
|
||||
}
|
||||
unsafe {
|
||||
if ffi::secp256k1_ec_pubkey_tweak_add(secp.ctx, &mut self.0 as *mut _,
|
||||
other.as_c_ptr()) == 1 {
|
||||
if ffi::secp256k1_ec_pubkey_tweak_add(secp.ctx, &mut self.0, other.as_c_ptr()) == 1 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(Error::InvalidTweak)
|
||||
|
@ -353,8 +352,7 @@ impl PublicKey {
|
|||
return Err(Error::InvalidTweak);
|
||||
}
|
||||
unsafe {
|
||||
if ffi::secp256k1_ec_pubkey_tweak_mul(secp.ctx, &mut self.0 as *mut _,
|
||||
other.as_c_ptr()) == 1 {
|
||||
if ffi::secp256k1_ec_pubkey_tweak_mul(secp.ctx, &mut self.0, other.as_c_ptr()) == 1 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(Error::InvalidTweak)
|
||||
|
|
|
@ -361,13 +361,13 @@ impl Signature {
|
|||
/// Obtains a raw pointer suitable for use with FFI functions
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const ffi::Signature {
|
||||
&self.0 as *const _
|
||||
&self.0
|
||||
}
|
||||
|
||||
/// Obtains a raw mutable pointer suitable for use with FFI functions
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&mut self) -> *mut ffi::Signature {
|
||||
&mut self.0 as *mut _
|
||||
&mut self.0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -82,13 +82,13 @@ impl RecoverableSignature {
|
|||
/// Obtains a raw pointer suitable for use with FFI functions
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const ffi::RecoverableSignature {
|
||||
&self.0 as *const _
|
||||
&self.0
|
||||
}
|
||||
|
||||
/// Obtains a raw mutable pointer suitable for use with FFI functions
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&mut self) -> *mut ffi::RecoverableSignature {
|
||||
&mut self.0 as *mut _
|
||||
&mut self.0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -104,13 +104,13 @@ impl KeyPair {
|
|||
/// Obtains a raw const pointer suitable for use with FFI functions
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const ffi::KeyPair {
|
||||
&self.0 as *const _
|
||||
&self.0
|
||||
}
|
||||
|
||||
/// Obtains a raw mutable pointer suitable for use with FFI functions
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&mut self) -> *mut ffi::KeyPair {
|
||||
&mut self.0 as *mut _
|
||||
&mut self.0
|
||||
}
|
||||
|
||||
/// Creates a Schnorr KeyPair directly from a secret key slice
|
||||
|
@ -181,7 +181,7 @@ impl KeyPair {
|
|||
unsafe {
|
||||
let err = ffi::secp256k1_keypair_xonly_tweak_add(
|
||||
secp.ctx,
|
||||
&mut self.0 as *mut _,
|
||||
&mut self.0,
|
||||
tweak.as_c_ptr(),
|
||||
);
|
||||
|
||||
|
@ -198,13 +198,13 @@ impl PublicKey {
|
|||
/// Obtains a raw const pointer suitable for use with FFI functions
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const ffi::XOnlyPublicKey {
|
||||
&self.0 as *const _
|
||||
&self.0
|
||||
}
|
||||
|
||||
/// Obtains a raw mutable pointer suitable for use with FFI functions
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&mut self) -> *mut ffi::XOnlyPublicKey {
|
||||
&mut self.0 as *mut _
|
||||
&mut self.0
|
||||
}
|
||||
|
||||
/// Creates a new Schnorr public key from a Schnorr key pair
|
||||
|
@ -295,8 +295,8 @@ impl PublicKey {
|
|||
let mut parity: ::secp256k1_sys::types::c_int = 0;
|
||||
err = ffi::secp256k1_xonly_pubkey_from_pubkey(
|
||||
secp.ctx,
|
||||
&mut self.0 as *mut _,
|
||||
&mut parity as *mut _,
|
||||
&mut self.0,
|
||||
&mut parity,
|
||||
&pubkey,
|
||||
);
|
||||
|
||||
|
@ -334,7 +334,7 @@ impl PublicKey {
|
|||
secp.ctx,
|
||||
tweaked_ser.as_c_ptr(),
|
||||
if tweaked_parity { 1 } else { 0 },
|
||||
&self.0 as *const _,
|
||||
&self.0,
|
||||
tweak.as_c_ptr(),
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue