Skip to content

Commit

Permalink
Add __rust_alloc_zeroed to naive_ralloc
Browse files Browse the repository at this point in the history
This is fallout from rust-lang/rust#40409 which requires that all
allocators provide a `__rust_alloc_zeroed` function.

Fixes japaric#136.
  • Loading branch information
tbu- authored and anatol committed Apr 28, 2017
1 parent 98ac61b commit 9045052
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions naive_ralloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9045052

Please sign in to comment.