about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-06-29 23:08:00 -0400
committerDaniel Micay <danielmicay@gmail.com>2013-06-30 16:22:55 -0400
commit408eef0d89f4520b5ede7e5868a8ca1bc83795bc (patch)
treec9e152eaed776bcd764360da97f0d7ba5fd9b7b4 /src/libstd
parent350a5c0b722038a3743058a7a824cfa6ac7094da (diff)
downloadrust-408eef0d89f4520b5ede7e5868a8ca1bc83795bc.tar.gz
rust-408eef0d89f4520b5ede7e5868a8ca1bc83795bc.zip
stop initializing ref_count in exchange_alloc
this is never read anymore
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/rt/global_heap.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/libstd/rt/global_heap.rs b/src/libstd/rt/global_heap.rs
index 3994b722f59..5d4ac37055c 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