From a881f7d0081b66ed0545231de0ab7a67114893bf Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 15 Mar 2014 16:28:53 -0700 Subject: [PATCH] De-~[] ssl --- ssl/error.rs | 5 +++-- ssl/mod.rs | 16 ++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ssl/error.rs b/ssl/error.rs index 296812c3..6a89b678 100644 --- a/ssl/error.rs +++ b/ssl/error.rs @@ -1,5 +1,6 @@ use std::libc::c_ulong; use std::io::IoError; +use std::vec_ng::Vec; use ssl::ffi; @@ -11,7 +12,7 @@ pub enum SslError { /// The SSL session has been closed by the other end SslSessionClosed, /// An error in the OpenSSL library - OpenSslErrors(~[OpensslError]) + OpenSslErrors(Vec) } /// An error from the OpenSSL library @@ -44,7 +45,7 @@ impl SslError { /// Creates a new `OpenSslErrors` with the current contents of the error /// stack. pub fn get() -> SslError { - let mut errs = ~[]; + let mut errs = vec!(); loop { match unsafe { ffi::ERR_get_error() } { 0 => break, diff --git a/ssl/mod.rs b/ssl/mod.rs index b28e072c..807cf36f 100644 --- a/ssl/mod.rs +++ b/ssl/mod.rs @@ -4,7 +4,7 @@ use std::libc::{c_int, c_void, c_char}; use std::ptr; use std::io::{IoResult, IoError, OtherIoError, Stream, Reader, Writer}; use std::unstable::mutex::NativeMutex; -use std::vec; +use std::vec_ng::Vec; use ssl::error::{SslError, SslSessionClosed, StreamError}; @@ -14,7 +14,7 @@ mod ffi; mod tests; static mut VERIFY_IDX: c_int = -1; -static mut MUTEXES: *mut ~[NativeMutex] = 0 as *mut ~[NativeMutex]; +static mut MUTEXES: *mut Vec = 0 as *mut Vec; macro_rules! try_ssl( ($e:expr) => ( @@ -37,7 +37,7 @@ fn init() { VERIFY_IDX = verify_idx; let num_locks = ffi::CRYPTO_num_locks(); - let mutexes = ~vec::from_fn(num_locks as uint, |_| NativeMutex::new()); + let mutexes = ~Vec::from_fn(num_locks as uint, |_| NativeMutex::new()); MUTEXES = cast::transmute(mutexes); ffi::CRYPTO_set_locking_callback(locking_function); @@ -90,7 +90,7 @@ pub enum SslVerifyMode { extern "C" fn locking_function(mode: c_int, n: c_int, _file: *c_char, _line: c_int) { unsafe { - let mutex = &mut (*MUTEXES)[n as uint]; + let mutex = (*MUTEXES).get_mut(n as uint); if mode & ffi::CRYPTO_LOCK != 0 { mutex.lock_noguard(); @@ -446,7 +446,7 @@ impl MemBio { pub struct SslStream { priv stream: S, priv ssl: Ssl, - priv buf: ~[u8] + priv buf: Vec } impl SslStream { @@ -462,7 +462,7 @@ impl SslStream { stream: stream, ssl: ssl, // Maximum TLS record size is 16k - buf: vec::from_elem(16 * 1024, 0u8) + buf: Vec::from_elem(16 * 1024, 0u8) }; match ssl.in_retry_wrapper(|ssl| { ssl.connect() }) { @@ -490,7 +490,7 @@ impl SslStream { match self.ssl.get_error(ret) { ErrorWantRead => { try_ssl!(self.flush()); - let len = try_ssl!(self.stream.read(self.buf)); + let len = try_ssl!(self.stream.read(self.buf.as_mut_slice())); self.ssl.get_rbio().write(self.buf.slice_to(len)); } ErrorWantWrite => { try_ssl!(self.flush()) } @@ -503,7 +503,7 @@ impl SslStream { fn write_through(&mut self) -> IoResult<()> { loop { - match self.ssl.get_wbio().read(self.buf) { + match self.ssl.get_wbio().read(self.buf.as_mut_slice()) { Some(len) => try!(self.stream.write(self.buf.slice_to(len))), None => break };