diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-04-09 01:31:23 -0400 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-04-14 01:15:46 -0400 |
| commit | d9595d1737677dd61d9f52f674c34f13d708e39c (patch) | |
| tree | 304855240a098090a217dc325c4ca377b31d9ba2 /src/libcore/unstable/exchange_alloc.rs | |
| parent | 4bfa3c6663ad6facdbdb8bd533442b050085f753 (diff) | |
| download | rust-d9595d1737677dd61d9f52f674c34f13d708e39c.tar.gz rust-d9595d1737677dd61d9f52f674c34f13d708e39c.zip | |
core: remove unnecessary unsafe blocks/functions
Diffstat (limited to 'src/libcore/unstable/exchange_alloc.rs')
| -rw-r--r-- | src/libcore/unstable/exchange_alloc.rs | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/libcore/unstable/exchange_alloc.rs b/src/libcore/unstable/exchange_alloc.rs index fdf99e9dffe..8ca5486d929 100644 --- a/src/libcore/unstable/exchange_alloc.rs +++ b/src/libcore/unstable/exchange_alloc.rs @@ -19,27 +19,25 @@ use ptr::null; use intrinsic::TyDesc; pub unsafe fn malloc(td: *TypeDesc, size: uint) -> *c_void { - unsafe { - assert!(td.is_not_null()); + assert!(td.is_not_null()); - let total_size = get_box_size(size, (*td).align); - let p = c_malloc(total_size as size_t); - assert!(p.is_not_null()); + let total_size = get_box_size(size, (*td).align); + let p = c_malloc(total_size as size_t); + assert!(p.is_not_null()); - // FIXME #3475: Converting between our two different tydesc types - let td: *TyDesc = transmute(td); + // FIXME #3475: Converting between our two different tydesc types + let td: *TyDesc = transmute(td); - let box: &mut BoxRepr = transmute(p); - box.header.ref_count = -1; // Exchange values not ref counted - box.header.type_desc = td; - box.header.prev = null(); - box.header.next = null(); + let box: &mut BoxRepr = transmute(p); + box.header.ref_count = -1; // Exchange values not ref counted + box.header.type_desc = td; + box.header.prev = null(); + box.header.next = null(); - let exchange_count = &mut *rust_get_exchange_count_ptr(); - atomic_xadd(exchange_count, 1); + let exchange_count = &mut *rust_get_exchange_count_ptr(); + atomic_xadd(exchange_count, 1); - return transmute(box); - } + return transmute(box); } /** Thin wrapper around libc::malloc, none of the box header |
