Skip to content

Commit e115a58

Browse files
authored
Merge pull request #5 from oli-obk/patch-1
Update alloc API to latest nightly
2 parents 688bc7f + d953f72 commit e115a58

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ pub extern "C" fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
9797
})
9898
}
9999

100+
#[doc(hidden)]
101+
#[no_mangle]
102+
pub extern fn __rust_allocate_zeroed(size: usize, align: usize) -> *mut u8 {
103+
let ptr = __rust_allocate(size, align);
104+
if !ptr.is_null() {
105+
unsafe {
106+
ptr::write_bytes(ptr, 0, size);
107+
}
108+
}
109+
ptr
110+
}
111+
100112
/// Rust de-allocation function (c.f. free)
101113
#[doc(hidden)]
102114
#[no_mangle]

0 commit comments

Comments
 (0)