Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the global allocator, not the system allocator #947

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,15 +809,15 @@ pub mod __rt {
}

if_std! {
use std::alloc::{System, GlobalAlloc, Layout};
use std::alloc::{alloc, dealloc, Layout};
use std::mem;

#[no_mangle]
pub extern fn __wbindgen_malloc(size: usize) -> *mut u8 {
let align = mem::align_of::<usize>();
if let Ok(layout) = Layout::from_size_align(size, align) {
unsafe {
let ptr = System.alloc(layout);
let ptr = alloc(layout);
if !ptr.is_null() {
return ptr
}
Expand All @@ -836,7 +836,7 @@ pub mod __rt {
}
let align = mem::align_of::<usize>();
let layout = Layout::from_size_align_unchecked(size, align);
System.dealloc(ptr, layout);
dealloc(ptr, layout);
}
}

Expand Down