IoResult -> io::Result, copy_nonoverlapping_memory -> copy_nonoverlapping

This commit is contained in:
Andrew Poelstra 2015-03-25 14:10:02 -05:00
parent 1e24549ef5
commit d0519f0b3a
3 changed files with 26 additions and 26 deletions

View File

@ -15,7 +15,7 @@
//! Public/Private keys
use std::intrinsics::copy_nonoverlapping_memory;
use std::intrinsics::copy_nonoverlapping;
use std::cmp;
use std::fmt;
use std::rand::Rng;
@ -67,7 +67,7 @@ fn random_32_bytes<R:Rng>(rng: &mut R) -> [u8; 32] {
fn bits2octets(data: &[u8]) -> [u8; 32] {
let mut ret = [0; 32];
unsafe {
copy_nonoverlapping_memory(ret.as_mut_ptr(),
copy_nonoverlapping(ret.as_mut_ptr(),
data.as_ptr(),
cmp::min(data.len(), 32));
}
@ -88,7 +88,7 @@ impl Nonce {
constants::NONCE_SIZE => {
let mut ret = [0; constants::NONCE_SIZE];
unsafe {
copy_nonoverlapping_memory(ret.as_mut_ptr(),
copy_nonoverlapping(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
}
@ -182,7 +182,7 @@ impl SecretKey {
if ffi::secp256k1_ec_seckey_verify(data.as_ptr()) == 0 {
return Err(InvalidSecretKey);
}
copy_nonoverlapping_memory(ret.as_mut_ptr(),
copy_nonoverlapping(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
}
@ -276,7 +276,7 @@ impl PublicKey {
data.len() as ::libc::c_int) == 0 {
return Err(InvalidPublicKey);
}
copy_nonoverlapping_memory(ret.as_mut_ptr(),
copy_nonoverlapping(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
}
@ -285,7 +285,7 @@ impl PublicKey {
constants::UNCOMPRESSED_PUBLIC_KEY_SIZE => {
let mut ret = [0; constants::UNCOMPRESSED_PUBLIC_KEY_SIZE];
unsafe {
copy_nonoverlapping_memory(ret.as_mut_ptr(),
copy_nonoverlapping(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
}

View File

@ -79,10 +79,10 @@ macro_rules! impl_array_newtype {
#[inline]
fn clone(&self) -> $thing {
unsafe {
use std::intrinsics::copy_nonoverlapping_memory;
use std::intrinsics::copy_nonoverlapping;
use std::mem;
let mut ret: $thing = mem::uninitialized();
copy_nonoverlapping_memory(ret.as_mut_ptr(),
copy_nonoverlapping(ret.as_mut_ptr(),
self.as_ptr(),
mem::size_of::<$thing>());
ret

View File

@ -41,8 +41,8 @@ extern crate libc;
extern crate serialize;
extern crate test;
use std::intrinsics::copy_nonoverlapping_memory;
use std::io::IoResult;
use std::intrinsics::copy_nonoverlapping;
use std::io;
use std::rand::{OsRng, Rng, SeedableRng};
use std::sync::{Once, ONCE_INIT};
use libc::c_int;
@ -103,7 +103,7 @@ impl Signature {
if data.len() <= constants::MAX_SIGNATURE_SIZE {
let mut ret = [0; constants::MAX_SIGNATURE_SIZE];
unsafe {
copy_nonoverlapping_memory(ret.as_mut_ptr(),
copy_nonoverlapping(ret.as_mut_ptr(),
data.as_ptr(),
data.len());
}
@ -158,7 +158,7 @@ pub fn init() {
impl Secp256k1 {
/// Constructs a new secp256k1 engine.
pub fn new() -> IoResult<Secp256k1> {
pub fn new() -> io::Result<Secp256k1> {
init();
let mut osrng = try!(OsRng::new());
let mut seed = [0; 2048];