Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: nikomatsakis <niko@alum.mit.edu>
  • Loading branch information
LeSeulArtichaut and nikomatsakis committed Jun 19, 2020
1 parent 39e29ce commit 7b63986
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/liballoc/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,16 @@ unsafe impl AllocRef for Global {
}
ReallocPlacement::MayMove => {
// `realloc` probably checks for `new_size > size` or something similar.
unsafe {
let ptr = unsafe {
intrinsics::assume(new_size > size);
let ptr = realloc(ptr.as_ptr(), layout, new_size);
let memory =
MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size };
realloc(ptr.as_ptr(), layout, new_size)
};
let memory =
MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size };
unsafe {
init.init_offset(memory, size);
Ok(memory)
}
Ok(memory)
}
}
}
Expand Down Expand Up @@ -255,11 +257,11 @@ unsafe impl AllocRef for Global {
}
ReallocPlacement::MayMove => {
// `realloc` probably checks for `new_size < size` or something similar.
unsafe {
let ptr = unsafe {
intrinsics::assume(new_size < size);
let ptr = realloc(ptr.as_ptr(), layout, new_size);
Ok(MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size })
}
realloc(ptr.as_ptr(), layout, new_size)
};
Ok(MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size })
}
}
}
Expand Down

0 comments on commit 7b63986

Please sign in to comment.