We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents d806c96 + 5af8646 commit bcec83aCopy full SHA for bcec83a
src/libcore/task/local_data_priv.rs
@@ -94,12 +94,10 @@ unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap {
94
let map_ptr = rt::rust_get_task_local_data(task);
95
if map_ptr.is_null() {
96
let map: TaskLocalMap = @mut ~[];
97
+ // NB: This bumps the ref count before converting to an unsafe pointer,
98
+ // keeping the map alive until TLS is destroyed
99
rt::rust_set_task_local_data(task, cast::transmute(map));
100
rt::rust_task_local_data_atexit(task, cleanup_task_local_map_extern_cb);
- // Also need to reference it an extra time to keep it for now.
- let nonmut = cast::transmute::<TaskLocalMap,
101
- @~[Option<TaskLocalElement>]>(map);
102
- cast::bump_box_refcount(nonmut);
103
map
104
} else {
105
let map = cast::transmute(map_ptr);
0 commit comments