Skip to content

Commit

Permalink
fix: not nightly, not allocator-api2 path
Browse files Browse the repository at this point in the history
  • Loading branch information
morrisonlevi committed May 4, 2024
1 parent e93a371 commit 602a381
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/raw/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ mod inner {
unsafe impl Allocator for Global {
#[inline]
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, ()> {
unsafe { NonNull::new(alloc(layout)).ok_or(()) }
match unsafe { NonNull::new(alloc(layout)) } {
Some(ptr) => Ok(NonNull::slice_from_raw_parts(ptr, layout.size())),
None => Err(()),
}
}
#[inline]
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
Expand Down

0 comments on commit 602a381

Please sign in to comment.