aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/bio.rs
diff options
context:
space:
mode:
Diffstat (limited to 'openssl/src/bio.rs')
-rw-r--r--openssl/src/bio.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/openssl/src/bio.rs b/openssl/src/bio.rs
index 0d82a6c3..5fc4f31f 100644
--- a/openssl/src/bio.rs
+++ b/openssl/src/bio.rs
@@ -4,6 +4,7 @@ use std::slice;
use libc::c_int;
use ffi;
+use cvt_p;
use error::ErrorStack;
pub struct MemBioSlice<'a>(*mut ffi::BIO, PhantomData<&'a [u8]>);
@@ -21,9 +22,8 @@ impl<'a> MemBioSlice<'a> {
ffi::init();
assert!(buf.len() <= c_int::max_value() as usize);
- let bio = unsafe {
- try_ssl_null!(ffi::BIO_new_mem_buf(buf.as_ptr() as *const _, buf.len() as c_int))
- };
+ let bio =
+ unsafe { try!(cvt_p(BIO_new_mem_buf(buf.as_ptr() as *const _, buf.len() as c_int))) };
Ok(MemBioSlice(bio, PhantomData))
}
@@ -47,9 +47,7 @@ impl MemBio {
pub fn new() -> Result<MemBio, ErrorStack> {
ffi::init();
- let bio = unsafe {
- try_ssl_null!(ffi::BIO_new(ffi::BIO_s_mem()))
- };
+ let bio = unsafe { try!(cvt_p(ffi::BIO_new(ffi::BIO_s_mem()))) };
Ok(MemBio(bio))
}
@@ -65,3 +63,12 @@ impl MemBio {
}
}
}
+
+#[cfg(not(ossl101))]
+use ffi::BIO_new_mem_buf;
+
+#[cfg(ossl101)]
+#[allow(bad_style)]
+unsafe fn BIO_new_mem_buf(buf: *const ::libc::c_void, len: ::libc::c_int) -> *mut ffi::BIO {
+ ffi::BIO_new_mem_buf(buf as *mut _, len)
+}