From 408eef0d89f4520b5ede7e5868a8ca1bc83795bc Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sat, 29 Jun 2013 23:08:00 -0400 Subject: [PATCH] stop initializing ref_count in exchange_alloc this is never read anymore --- src/libstd/rt/global_heap.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/libstd/rt/global_heap.rs b/src/libstd/rt/global_heap.rs index 3994b722f592..5d4ac37055ca 100644 --- a/src/libstd/rt/global_heap.rs +++ b/src/libstd/rt/global_heap.rs @@ -43,6 +43,27 @@ pub unsafe fn malloc_raw(size: uint) -> *c_void { } // FIXME #4942: Make these signatures agree with exchange_alloc's signatures +#[cfg(stage0, not(test))] +#[lang="exchange_malloc"] +#[inline] +pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char { + let td = td as *TyDesc; + let size = size as uint; + + assert!(td.is_not_null()); + + let total_size = get_box_size(size, (*td).align); + let p = malloc_raw(total_size as uint); + + let box: *mut BoxRepr = p as *mut BoxRepr; + (*box).header.ref_count = -1; + (*box).header.type_desc = td; + + box as *c_char +} + +// FIXME #4942: Make these signatures agree with exchange_alloc's signatures +#[cfg(not(stage0), not(test))] #[lang="exchange_malloc"] #[inline] pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char { @@ -55,7 +76,6 @@ pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char { let p = malloc_raw(total_size as uint); let box: *mut BoxRepr = p as *mut BoxRepr; - (*box).header.ref_count = -1; // Exchange values not ref counted (*box).header.type_desc = td; box as *c_char