Skip to content

Commit 1484864

Browse files
committed
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 japaric#136.
1 parent a8d611a commit 1484864

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

naive_ralloc/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ pub extern fn __rust_allocate(size: usize, _align: usize) -> *mut u8 {
3636
allocate(size)
3737
}
3838

39+
#[linkage = "external"]
40+
#[no_mangle]
41+
pub extern fn __rust_allocate_zeroed(size: usize, align: usize) -> *mut u8 {
42+
unsafe {
43+
let result = __rust_allocate(size, align);
44+
intrinsics::write_bytes(result, 0, size);
45+
result
46+
}
47+
}
48+
3949
#[linkage = "external"]
4050
#[no_mangle]
4151
pub extern fn __rust_deallocate(_ptr: *mut u8, _old_size: usize, _align: usize) {

0 commit comments

Comments
 (0)