Skip to content

Commit bcec83a

Browse files
committed
auto merge of #6493 : brson/rust/tls, r=thestinger
2 parents d806c96 + 5af8646 commit bcec83a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/libcore/task/local_data_priv.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,10 @@ unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap {
9494
let map_ptr = rt::rust_get_task_local_data(task);
9595
if map_ptr.is_null() {
9696
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
9799
rt::rust_set_task_local_data(task, cast::transmute(map));
98100
rt::rust_task_local_data_atexit(task, cleanup_task_local_map_extern_cb);
99-
// Also need to reference it an extra time to keep it for now.
100-
let nonmut = cast::transmute::<TaskLocalMap,
101-
@~[Option<TaskLocalElement>]>(map);
102-
cast::bump_box_refcount(nonmut);
103101
map
104102
} else {
105103
let map = cast::transmute(map_ptr);

0 commit comments

Comments
 (0)