Skip to content

Commit 408eef0

Browse files
committed
stop initializing ref_count in exchange_alloc
this is never read anymore
1 parent 350a5c0 commit 408eef0

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/libstd/rt/global_heap.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ pub unsafe fn malloc_raw(size: uint) -> *c_void {
4343
}
4444

4545
// FIXME #4942: Make these signatures agree with exchange_alloc's signatures
46+
#[cfg(stage0, not(test))]
47+
#[lang="exchange_malloc"]
48+
#[inline]
49+
pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
50+
let td = td as *TyDesc;
51+
let size = size as uint;
52+
53+
assert!(td.is_not_null());
54+
55+
let total_size = get_box_size(size, (*td).align);
56+
let p = malloc_raw(total_size as uint);
57+
58+
let box: *mut BoxRepr = p as *mut BoxRepr;
59+
(*box).header.ref_count = -1;
60+
(*box).header.type_desc = td;
61+
62+
box as *c_char
63+
}
64+
65+
// FIXME #4942: Make these signatures agree with exchange_alloc's signatures
66+
#[cfg(not(stage0), not(test))]
4667
#[lang="exchange_malloc"]
4768
#[inline]
4869
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 {
5576
let p = malloc_raw(total_size as uint);
5677

5778
let box: *mut BoxRepr = p as *mut BoxRepr;
58-
(*box).header.ref_count = -1; // Exchange values not ref counted
5979
(*box).header.type_desc = td;
6080

6181
box as *c_char

0 commit comments

Comments
 (0)