Clean up bio

This commit is contained in:
Steven Fackler 2017-01-01 10:18:43 -08:00
parent 7e75c76bb4
commit 0e0bee50a5
1 changed files with 7 additions and 7 deletions

View File

@ -68,10 +68,10 @@ pub unsafe fn get_mut<'a, S: 'a>(bio: *mut BIO) -> &'a mut S {
} }
unsafe fn state<'a, S: 'a>(bio: *mut BIO) -> &'a mut StreamState<S> { unsafe fn state<'a, S: 'a>(bio: *mut BIO) -> &'a mut StreamState<S> {
mem::transmute(compat::BIO_get_data(bio)) &mut *(compat::BIO_get_data(bio) as *mut _)
} }
unsafe extern "C" fn bwrite<S: Write>(bio: *mut BIO, buf: *const c_char, len: c_int) -> c_int { unsafe extern fn bwrite<S: Write>(bio: *mut BIO, buf: *const c_char, len: c_int) -> c_int {
BIO_clear_retry_flags(bio); BIO_clear_retry_flags(bio);
let state = state::<S>(bio); let state = state::<S>(bio);
@ -93,7 +93,7 @@ unsafe extern "C" fn bwrite<S: Write>(bio: *mut BIO, buf: *const c_char, len: c_
} }
} }
unsafe extern "C" fn bread<S: Read>(bio: *mut BIO, buf: *mut c_char, len: c_int) -> c_int { unsafe extern fn bread<S: Read>(bio: *mut BIO, buf: *mut c_char, len: c_int) -> c_int {
BIO_clear_retry_flags(bio); BIO_clear_retry_flags(bio);
let state = state::<S>(bio); let state = state::<S>(bio);
@ -123,11 +123,11 @@ fn retriable_error(err: &io::Error) -> bool {
} }
} }
unsafe extern "C" fn bputs<S: Write>(bio: *mut BIO, s: *const c_char) -> c_int { unsafe extern fn bputs<S: Write>(bio: *mut BIO, s: *const c_char) -> c_int {
bwrite::<S>(bio, s, strlen(s) as c_int) bwrite::<S>(bio, s, strlen(s) as c_int)
} }
unsafe extern "C" fn ctrl<S: Write>(bio: *mut BIO, unsafe extern fn ctrl<S: Write>(bio: *mut BIO,
cmd: c_int, cmd: c_int,
_num: c_long, _num: c_long,
_ptr: *mut c_void) _ptr: *mut c_void)
@ -151,7 +151,7 @@ unsafe extern "C" fn ctrl<S: Write>(bio: *mut BIO,
} }
} }
unsafe extern "C" fn create(bio: *mut BIO) -> c_int { unsafe extern fn create(bio: *mut BIO) -> c_int {
compat::BIO_set_init(bio, 0); compat::BIO_set_init(bio, 0);
compat::BIO_set_num(bio, 0); compat::BIO_set_num(bio, 0);
compat::BIO_set_data(bio, ptr::null_mut()); compat::BIO_set_data(bio, ptr::null_mut());
@ -159,7 +159,7 @@ unsafe extern "C" fn create(bio: *mut BIO) -> c_int {
1 1
} }
unsafe extern "C" fn destroy<S>(bio: *mut BIO) -> c_int { unsafe extern fn destroy<S>(bio: *mut BIO) -> c_int {
if bio.is_null() { if bio.is_null() {
return 0; return 0;
} }