diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-08-29 16:00:36 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-09-01 18:18:29 -0700 |
| commit | d777e5133360876baa4213f81a33934f04768a0f (patch) | |
| tree | 13d3daefe774fc627d454cda2a043b0f95b57072 /src/libcore/vec.rs | |
| parent | 6bfc80f8fb5b764d0e288a41960876fbbe662af2 (diff) | |
Demode reinterpret_cast
Diffstat (limited to 'src/libcore/vec.rs')
| -rw-r--r-- | src/libcore/vec.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 2e93788e9ac..3f5051ac55b 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -167,7 +167,7 @@ fn reserve_at_least<T>(&v: ~[const T], n: uint) { #[inline(always)] pure fn capacity<T>(&&v: ~[const T]) -> uint { unsafe { - let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(addr_of(v)); + let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(&addr_of(v)); (**repr).alloc / sys::size_of::<T>() } } @@ -335,7 +335,7 @@ pure fn view<T>(v: &[T], start: uint, end: uint) -> &[T] { do as_buf(v) |p, _len| { unsafe { ::unsafe::reinterpret_cast( - (ptr::offset(p, start), (end - start) * sys::size_of::<T>())) + &(ptr::offset(p, start), (end - start) * sys::size_of::<T>())) } } } @@ -347,7 +347,7 @@ pure fn mut_view<T>(v: &[mut T], start: uint, end: uint) -> &[mut T] { do as_buf(v) |p, _len| { unsafe { ::unsafe::reinterpret_cast( - (ptr::offset(p, start), (end - start) * sys::size_of::<T>())) + &(ptr::offset(p, start), (end - start) * sys::size_of::<T>())) } } } @@ -359,7 +359,7 @@ pure fn const_view<T>(v: &[const T], start: uint, end: uint) -> &[const T] { do as_buf(v) |p, _len| { unsafe { ::unsafe::reinterpret_cast( - (ptr::offset(p, start), (end - start) * sys::size_of::<T>())) + &(ptr::offset(p, start), (end - start) * sys::size_of::<T>())) } } } @@ -558,7 +558,7 @@ fn swap_remove<T>(&v: ~[const T], index: uint) -> T { #[inline(always)] fn push<T>(&v: ~[const T], +initval: T) { unsafe { - let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(addr_of(v)); + let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(&addr_of(v)); let fill = (**repr).fill; if (**repr).alloc > fill { push_fast(v, initval); @@ -572,7 +572,7 @@ fn push<T>(&v: ~[const T], +initval: T) { // This doesn't bother to make sure we have space. #[inline(always)] // really pretty please unsafe fn push_fast<T>(&v: ~[const T], +initval: T) { - let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(addr_of(v)); + let repr: **unsafe::VecRepr = ::unsafe::reinterpret_cast(&addr_of(v)); let fill = (**repr).fill; (**repr).fill += sys::size_of::<T>(); let p = ptr::addr_of((**repr).data); @@ -1357,7 +1357,7 @@ pure fn windowed<TT: copy>(nn: uint, xx: &[TT]) -> ~[~[TT]] { pure fn as_buf<T,U>(s: &[const T], f: fn(*T, uint) -> U) -> U { unsafe { - let v : *(*T,uint) = ::unsafe::reinterpret_cast(ptr::addr_of(s)); + let v : *(*T,uint) = ::unsafe::reinterpret_cast(&ptr::addr_of(s)); let (buf,len) = *v; f(buf, len / sys::size_of::<T>()) } @@ -1369,7 +1369,7 @@ pure fn as_const_buf<T,U>(s: &[const T], f: fn(*const T, uint) -> U) -> U { do as_buf(s) |p, len| { unsafe { - let pp : *const T = ::unsafe::reinterpret_cast(p); + let pp : *const T = ::unsafe::reinterpret_cast(&p); f(pp, len) } } @@ -1381,7 +1381,7 @@ pure fn as_mut_buf<T,U>(s: &[mut T], f: fn(*mut T, uint) -> U) -> U { do as_buf(s) |p, len| { unsafe { - let pp : *mut T = ::unsafe::reinterpret_cast(p); + let pp : *mut T = ::unsafe::reinterpret_cast(&p); f(pp, len) } } @@ -1740,7 +1740,7 @@ mod unsafe { */ #[inline(always)] unsafe fn set_len<T>(&&v: ~[const T], new_len: uint) { - let repr: **VecRepr = ::unsafe::reinterpret_cast(addr_of(v)); + let repr: **VecRepr = ::unsafe::reinterpret_cast(&addr_of(v)); (**repr).fill = new_len * sys::size_of::<T>(); } @@ -1755,15 +1755,15 @@ mod unsafe { */ #[inline(always)] unsafe fn to_ptr<T>(v: ~[const T]) -> *T { - let repr: **VecRepr = ::unsafe::reinterpret_cast(addr_of(v)); - return ::unsafe::reinterpret_cast(addr_of((**repr).data)); + let repr: **VecRepr = ::unsafe::reinterpret_cast(&addr_of(v)); + return ::unsafe::reinterpret_cast(&addr_of((**repr).data)); } #[inline(always)] unsafe fn to_ptr_slice<T>(v: &[const T]) -> *T { - let repr: **SliceRepr = ::unsafe::reinterpret_cast(addr_of(v)); - return ::unsafe::reinterpret_cast(addr_of((**repr).data)); + let repr: **SliceRepr = ::unsafe::reinterpret_cast(&addr_of(v)); + return ::unsafe::reinterpret_cast(&addr_of((**repr).data)); } @@ -1775,7 +1775,7 @@ mod unsafe { unsafe fn form_slice<T,U>(p: *T, len: uint, f: fn(&& &[T]) -> U) -> U { let pair = (p, len * sys::size_of::<T>()); let v : *(&blk/[T]) = - ::unsafe::reinterpret_cast(ptr::addr_of(pair)); + ::unsafe::reinterpret_cast(&ptr::addr_of(pair)); f(*v) } |
