diff options
| author | Florian Hahn <flo@fhahn.com> | 2013-12-12 22:27:26 +0100 |
|---|---|---|
| committer | Florian Hahn <flo@fhahn.com> | 2014-01-22 19:20:47 +0100 |
| commit | 2eb4f05850e25863f05a56b60931e9eb03944b56 (patch) | |
| tree | dbbb1b2aeb64ff54abf331d7be7bb9ce6615c9e0 /src/libstd/local_data.rs | |
| parent | 750d48b0ad1854b389ce1c209484f9146dc7aba0 (diff) | |
Replace C types with Rust types in libstd, closes #7313
Diffstat (limited to 'src/libstd/local_data.rs')
| -rw-r--r-- | src/libstd/local_data.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs index 7ef7a256c16..7406fe8ee40 100644 --- a/src/libstd/local_data.rs +++ b/src/libstd/local_data.rs @@ -41,10 +41,9 @@ local_data::get(key_vector, |opt| assert_eq!(*opt.unwrap(), ~[4])); // magic. use cast; -use libc; use prelude::*; use rt::task::{Task, LocalStorage}; -use util; +use util::replace; /** * Indexes a task-local data slot. This pointer is used for comparison to @@ -87,7 +86,7 @@ impl<T: 'static> LocalData for T {} // n.b. If TLS is used heavily in future, this could be made more efficient with // a proper map. #[doc(hidden)] -pub type Map = ~[Option<(*libc::c_void, TLSValue, LoanState)>]; +pub type Map = ~[Option<(*u8, TLSValue, LoanState)>]; type TLSValue = ~LocalData; // Gets the map from the runtime. Lazily initialises if not done so already. @@ -128,7 +127,7 @@ impl LoanState { } } -fn key_to_key_value<T: 'static>(key: Key<T>) -> *libc::c_void { +fn key_to_key_value<T: 'static>(key: Key<T>) -> *u8 { unsafe { cast::transmute(key) } } @@ -151,7 +150,7 @@ pub fn pop<T: 'static>(key: Key<T>) -> Option<T> { // Move the data out of the `entry` slot via util::replace. // This is guaranteed to succeed because we already matched // on `Some` above. - let data = match util::replace(entry, None) { + let data = match replace(entry, None) { Some((_, data, _)) => data, None => abort() }; @@ -302,7 +301,7 @@ pub fn set<T: 'static>(key: Key<T>, data: T) { let data = ~data as ~LocalData:; fn insertion_position(map: &mut Map, - key: *libc::c_void) -> Option<uint> { + key: *u8) -> Option<uint> { // First see if the map contains this key already let curspot = map.iter().position(|entry| { match *entry { |
