diff --git a/src/lib.rs b/src/lib.rs index 4791b2c..7147522 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -97,6 +97,18 @@ pub extern "C" fn __rust_allocate(size: usize, align: usize) -> *mut u8 { }) } +#[doc(hidden)] +#[no_mangle] +pub extern fn __rust_allocate_zeroed(size: usize, align: usize) -> *mut u8 { + let ptr = __rust_allocate(size, align); + if !ptr.is_null() { + unsafe { + ptr::write_bytes(ptr, 0, size); + } + } + ptr +} + /// Rust de-allocation function (c.f. free) #[doc(hidden)] #[no_mangle]