From 14848641c80bd2215635e1d692a10fa4681d6637 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Wed, 19 Apr 2017 20:22:18 +0200 Subject: [PATCH] Add `__rust_alloc_zeroed` to `naive_ralloc` This is fallout from rust-lang/rust#40409 which requires that all allocators provide a `__rust_alloc_zeroed` function. Fixes #136. --- naive_ralloc/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/naive_ralloc/src/lib.rs b/naive_ralloc/src/lib.rs index 7285abe02..2cffaeda0 100644 --- a/naive_ralloc/src/lib.rs +++ b/naive_ralloc/src/lib.rs @@ -36,6 +36,16 @@ pub extern fn __rust_allocate(size: usize, _align: usize) -> *mut u8 { allocate(size) } +#[linkage = "external"] +#[no_mangle] +pub extern fn __rust_allocate_zeroed(size: usize, align: usize) -> *mut u8 { + unsafe { + let result = __rust_allocate(size, align); + intrinsics::write_bytes(result, 0, size); + result + } +} + #[linkage = "external"] #[no_mangle] pub extern fn __rust_deallocate(_ptr: *mut u8, _old_size: usize, _align: usize) {