From 6ca6a3b80be1c7a5638156638a8a11e514bc3ef3 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 23 May 2012 19:21:50 -0700 Subject: [PATCH] rewrite arc to use region & expressions (also making it pass borrowck) --- src/libstd/arc.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 9c46db57627..8827713d933 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -6,11 +6,11 @@ export arc, get, clone; #[abi = "cdecl"] native mod rustrt { #[rust_stack] - fn rust_atomic_increment(p: *mut libc::intptr_t) + fn rust_atomic_increment(p: &mut libc::intptr_t) -> libc::intptr_t; #[rust_stack] - fn rust_atomic_decrement(p: *mut libc::intptr_t) + fn rust_atomic_decrement(p: &mut libc::intptr_t) -> libc::intptr_t; } @@ -21,7 +21,7 @@ type arc_data = { resource arc_destruct(data: *arc_data) { unsafe { - let ptr = ptr::mut_addr_of((*data).count); + let ptr = &mut (*data).count; let new_count = rustrt::rust_atomic_decrement(ptr); assert new_count >= 0; @@ -52,8 +52,7 @@ fn get(rc: &a.arc) -> &a.T { fn clone(rc: &arc) -> arc { let data = **rc; unsafe { - rustrt::rust_atomic_increment( - ptr::mut_addr_of((*data).count)); + rustrt::rust_atomic_increment(&mut (*data).count); } arc_destruct(**rc) }