diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2014-09-05 10:39:36 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2014-09-10 03:50:43 -0400 |
| commit | 72a92b2e14927aa2bedcc739aa8de62d66632ed9 (patch) | |
| tree | 4bff1f0a1bdfbc72e5e07c56faea7088fc0ad7f5 /src/liballoc | |
| parent | 92b09261e73eed19a71f3f0e781ee62676aae147 (diff) | |
| download | rust-72a92b2e14927aa2bedcc739aa8de62d66632ed9.tar.gz rust-72a92b2e14927aa2bedcc739aa8de62d66632ed9.zip | |
implement sized deallocation
Closes #13994
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/heap.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 204d8ee3a41..62010ca8916 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -178,7 +178,10 @@ mod imp { flags: c_int) -> *mut c_void; fn je_xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t; + #[cfg(stage0)] fn je_dallocx(ptr: *mut c_void, flags: c_int); + #[cfg(not(stage0))] + fn je_sdallocx(ptr: *mut c_void, size: size_t, flags: c_int); fn je_nallocx(size: size_t, flags: c_int) -> size_t; fn je_malloc_stats_print(write_cb: Option<extern "C" fn(cbopaque: *mut c_void, *const c_char)>, @@ -229,12 +232,20 @@ mod imp { } #[inline] + #[cfg(stage0)] pub unsafe fn deallocate(ptr: *mut u8, _size: uint, align: uint) { let flags = align_to_flags(align); je_dallocx(ptr as *mut c_void, flags) } #[inline] + #[cfg(not(stage0))] + pub unsafe fn deallocate(ptr: *mut u8, size: uint, align: uint) { + let flags = align_to_flags(align); + je_sdallocx(ptr as *mut c_void, size as size_t, flags) + } + + #[inline] pub fn usable_size(size: uint, align: uint) -> uint { let flags = align_to_flags(align); unsafe { je_nallocx(size as size_t, flags) as uint } |
