aboutsummaryrefslogtreecommitdiff
path: root/rand.rs
diff options
context:
space:
mode:
authorErick Tryzelaar <[email protected]>2013-12-18 07:30:16 -0800
committerErick Tryzelaar <[email protected]>2013-12-18 07:30:16 -0800
commit4e0257ab5991eaa6863d261f97dcf6ff8e6b7545 (patch)
treed58c184dae0040a0afbf9f4b8e8eb83e72cef314 /rand.rs
parentIntegrate with Travis (diff)
parentUpdate for latest rustc (0.9-pre ca54ad8) (diff)
downloadrust-openssl-4e0257ab5991eaa6863d261f97dcf6ff8e6b7545.tar.xz
rust-openssl-4e0257ab5991eaa6863d261f97dcf6ff8e6b7545.zip
Merge branch 'master' of https://github.com/kballard/rustcrypto
Diffstat (limited to 'rand.rs')
-rw-r--r--rand.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/rand.rs b/rand.rs
index eedac4ab..8e78c51c 100644
--- a/rand.rs
+++ b/rand.rs
@@ -4,19 +4,19 @@ use std::vec;
mod libcrypto {
use std::libc::c_int;
- #[link_args = "-lcrypto"]
+ #[link(name = "crypto")]
extern {
- fn RAND_bytes(buf: *mut u8, num: c_int) -> c_int;
+ pub fn RAND_bytes(buf: *mut u8, num: c_int) -> c_int;
}
}
pub fn rand_bytes(len: uint) -> ~[u8] {
let mut out = vec::with_capacity(len);
- do out.as_mut_buf |out_buf, len| {
+ out.as_mut_buf(|out_buf, len| {
let r = unsafe { libcrypto::RAND_bytes(out_buf, len as c_int) };
if r != 1 as c_int { fail!() }
- }
+ });
unsafe { vec::raw::set_len(&mut out, len); }
@@ -30,6 +30,6 @@ mod tests {
#[test]
fn test_rand_bytes() {
let bytes = rand_bytes(32u);
- println(fmt!("%?", bytes));
+ println!("{:?}", bytes);
}
}