diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-07-22 21:32:39 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-07-24 23:12:28 -0700 |
| commit | 7fd23e4fe26bc9d6eef9596593ba3ddbe83f4a10 (patch) | |
| tree | 040bfc01bf2a74228692a6b1efa781310761e114 /src/libstd/cleanup.rs | |
| parent | 467d381d3afce474309d6ba9a334fa9b463c3a7f (diff) | |
| download | rust-7fd23e4fe26bc9d6eef9596593ba3ddbe83f4a10.tar.gz rust-7fd23e4fe26bc9d6eef9596593ba3ddbe83f4a10.zip | |
Convert uses of transmute which don't need it
Diffstat (limited to 'src/libstd/cleanup.rs')
| -rw-r--r-- | src/libstd/cleanup.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/libstd/cleanup.rs b/src/libstd/cleanup.rs index 2ea10b09c8e..da24fef1578 100644 --- a/src/libstd/cleanup.rs +++ b/src/libstd/cleanup.rs @@ -13,7 +13,6 @@ use libc::c_void; use ptr::{mut_null}; use repr::BoxRepr; -use cast::transmute; use unstable::intrinsics::TyDesc; type DropGlue<'self> = &'self fn(**TyDesc, *c_void); @@ -40,18 +39,17 @@ unsafe fn each_live_alloc(read_next_before: bool, let box = local_heap::live_allocs(); let mut box: *mut BoxRepr = transmute(box); while box != mut_null() { - let next_before = transmute((*box).header.next); - let uniq = - (*box).header.ref_count == managed::raw::RC_MANAGED_UNIQUE; + let next_before = (*box).next; + let uniq = (*box).ref_count == managed::RC_MANAGED_UNIQUE; - if !f(box, uniq) { + if !f(box as *mut raw::Box<()>, uniq) { return false; } if read_next_before { box = next_before; } else { - box = transmute((*box).header.next); + box = (*box).next; } } return true; @@ -113,9 +111,9 @@ pub unsafe fn annihilate() { // callback, as the original value may have been freed. for each_live_alloc(false) |box, uniq| { if !uniq { - let tydesc: *TyDesc = transmute((*box).header.type_desc); - let data = transmute(&(*box).data); - ((*tydesc).drop_glue)(data); + let tydesc = (*box).type_desc; + let data = &(*box).data as *(); + ((*tydesc).drop_glue)(data as *i8); } } @@ -130,7 +128,7 @@ pub unsafe fn annihilate() { stats.n_bytes_freed += (*((*box).header.type_desc)).size + sys::size_of::<BoxRepr>(); - local_free(transmute(box)); + local_free(box as *u8); } } |
