about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libcore/task/local_data_priv.rs17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs
index 66808bf21aa..e32d18719bd 100644
--- a/src/libcore/task/local_data_priv.rs
+++ b/src/libcore/task/local_data_priv.rs
@@ -49,8 +49,8 @@ impl<T:Durable> LocalData for @T { }
 impl Eq for @LocalData {
     fn eq(&self, other: &@LocalData) -> bool {
         unsafe {
-            let ptr_a: (uint, uint) = cast::reinterpret_cast(&(*self));
-            let ptr_b: (uint, uint) = cast::reinterpret_cast(other);
+            let ptr_a: &(uint, uint) = cast::transmute(self);
+            let ptr_b: &(uint, uint) = cast::transmute(other);
             return ptr_a == ptr_b;
         }
     }
@@ -68,7 +68,7 @@ fn cleanup_task_local_map(map_ptr: *libc::c_void) {
         assert!(!map_ptr.is_null());
         // Get and keep the single reference that was created at the
         // beginning.
-        let _map: TaskLocalMap = cast::reinterpret_cast(&map_ptr);
+        let _map: TaskLocalMap = cast::transmute(map_ptr);
         // All local_data will be destroyed along with the map.
     }
 }
@@ -125,14 +125,9 @@ unsafe fn get_newsched_local_map(local: *mut LocalStorage) -> TaskLocalMap {
         &LocalStorage(ref mut map_ptr, ref mut at_exit) => {
             assert!((*map_ptr).is_null());
             let map: TaskLocalMap = @mut ~[];
-            // Use reinterpret_cast -- transmute would take map away from us also.
-            *map_ptr = cast::reinterpret_cast(&map);
+            *map_ptr = cast::transmute(map);
             let at_exit_fn: ~fn(*libc::c_void) = |p|cleanup_task_local_map(p);
             *at_exit = Some(at_exit_fn);
-            // Also need to reference it an extra time to keep it for now.
-            let nonmut = cast::transmute::<TaskLocalMap,
-            @~[Option<TaskLocalElement>]>(map);
-            cast::bump_box_refcount(nonmut);
             return map;
         }
     }
@@ -143,7 +138,7 @@ unsafe fn key_to_key_value<T:Durable>(
 
     // Keys are closures, which are (fnptr,envptr) pairs. Use fnptr.
     // Use reintepret_cast -- transmute would leak (forget) the closure.
-    let pair: (*libc::c_void, *libc::c_void) = cast::reinterpret_cast(&key);
+    let pair: (*libc::c_void, *libc::c_void) = cast::transmute(key);
     pair.first()
 }
 
@@ -213,7 +208,7 @@ pub unsafe fn local_set<T:Durable>(
     // own on it can be dropped when the box is destroyed. The unsafe pointer
     // does not have a reference associated with it, so it may become invalid
     // when the box is destroyed.
-    let data_ptr = cast::reinterpret_cast(&data);
+    let data_ptr = *cast::transmute::<&@T, &*libc::c_void>(&data);
     let data_box = @data as @LocalData;
     // Construct new entry to store in the map.
     let new_entry = Some((keyval, data_ptr, data_box));