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