Skip to content

Commit

Permalink
Remove bailout again and always ask for at least as many bytes as the…
Browse files Browse the repository at this point in the history
… requested alignment
  • Loading branch information
filmor committed Mar 15, 2024
1 parent f63205a commit 0059902
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions rustler/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ pub struct EnifAllocator;
unsafe impl GlobalAlloc for EnifAllocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
// TODO: Check enif_alloc's real alignment
if layout.align() > (((((layout.size()) - 1) / 8) + 1) * 8) {
return std::ptr::null_mut();
}
rustler_sys::enif_alloc(layout.size()) as *mut u8
rustler_sys::enif_alloc(layout.size().max(layout.align())) as *mut u8
}

unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
Expand Down

0 comments on commit 0059902

Please sign in to comment.