Removing usage of `mem::uninitialized()` and deprecating the `blank()` functions
Signed-off-by: Elichai Turkel <elichai.turkel@gmail.com>
This commit is contained in:
parent
dfe7ee54f9
commit
389e1e2449
|
@ -77,7 +77,8 @@ impl PublicKey {
|
|||
/// Create a new (zeroed) public key usable for the FFI interface
|
||||
pub fn new() -> PublicKey { PublicKey([0; 64]) }
|
||||
/// Create a new (uninitialized) public key usable for the FFI interface
|
||||
pub unsafe fn blank() -> PublicKey { mem::uninitialized() }
|
||||
#[deprecated(since = "0.15.3", note = "Please use the new function instead")]
|
||||
pub unsafe fn blank() -> PublicKey { PublicKey::new() }
|
||||
}
|
||||
|
||||
impl Default for PublicKey {
|
||||
|
@ -102,7 +103,8 @@ impl Signature {
|
|||
/// Create a new (zeroed) signature usable for the FFI interface
|
||||
pub fn new() -> Signature { Signature([0; 64]) }
|
||||
/// Create a new (uninitialized) signature usable for the FFI interface
|
||||
pub unsafe fn blank() -> Signature { mem::uninitialized() }
|
||||
#[deprecated(since = "0.15.3", note = "Please use the new function instead")]
|
||||
pub unsafe fn blank() -> Signature { Signature::new() }
|
||||
}
|
||||
|
||||
impl Default for Signature {
|
||||
|
@ -121,7 +123,8 @@ impl SharedSecret {
|
|||
/// Create a new (zeroed) signature usable for the FFI interface
|
||||
pub fn new() -> SharedSecret { SharedSecret([0; 32]) }
|
||||
/// Create a new (uninitialized) signature usable for the FFI interface
|
||||
pub unsafe fn blank() -> SharedSecret { mem::uninitialized() }
|
||||
#[deprecated(since = "0.15.3", note = "Please use the new function instead")]
|
||||
pub unsafe fn blank() -> SharedSecret { SharedSecret::new() }
|
||||
}
|
||||
|
||||
impl Default for SharedSecret {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#[cfg(any(test, feature = "rand"))] use rand::Rng;
|
||||
|
||||
use core::{fmt, mem, str};
|
||||
use core::{fmt, str};
|
||||
|
||||
use super::{from_hex, Secp256k1};
|
||||
use super::Error::{self, InvalidPublicKey, InvalidSecretKey};
|
||||
|
@ -338,7 +338,7 @@ impl PublicKey {
|
|||
/// to its own negation
|
||||
pub fn combine(&self, other: &PublicKey) -> Result<PublicKey, Error> {
|
||||
unsafe {
|
||||
let mut ret = mem::uninitialized();
|
||||
let mut ret = ffi::PublicKey::new();
|
||||
let ptrs = [self.as_ptr(), other.as_ptr()];
|
||||
if ffi::secp256k1_ec_pubkey_combine(
|
||||
ffi::secp256k1_context_no_precomp,
|
||||
|
|
|
@ -68,15 +68,8 @@ macro_rules! impl_array_newtype {
|
|||
impl Clone for $thing {
|
||||
#[inline]
|
||||
fn clone(&self) -> $thing {
|
||||
unsafe {
|
||||
use core::intrinsics::copy_nonoverlapping;
|
||||
use core::mem;
|
||||
let mut ret: $thing = mem::uninitialized();
|
||||
copy_nonoverlapping(self.as_ptr(),
|
||||
ret.as_mut_ptr(),
|
||||
$len);
|
||||
ret
|
||||
}
|
||||
let &$thing(ref dat) = self;
|
||||
$thing(dat.clone())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@ impl RecoverableSignature {
|
|||
/// Create a new (zeroed) signature usable for the FFI interface
|
||||
pub fn new() -> RecoverableSignature { RecoverableSignature([0; 65]) }
|
||||
/// Create a new (uninitialized) signature usable for the FFI interface
|
||||
pub unsafe fn blank() -> RecoverableSignature { mem::uninitialized() }
|
||||
#[deprecated(since = "0.15.3", note = "Please use the new function instead")]
|
||||
pub unsafe fn blank() -> RecoverableSignature { RecoverableSignature::new() }
|
||||
}
|
||||
|
||||
impl Default for RecoverableSignature {
|
||||
|
|
Loading…
Reference in New Issue