Skip to content

Commit

Permalink
Add alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
filmor committed Mar 15, 2024
1 parent b13d16c commit f63205a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rustler/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ pub struct EnifAllocator;

unsafe impl GlobalAlloc for EnifAllocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
// TODO: Check the requested alignment.
// 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
}

Expand Down

0 comments on commit f63205a

Please sign in to comment.