Skip to content

Commit

Permalink
Move Layouts instead of binding by reference
Browse files Browse the repository at this point in the history
  • Loading branch information
kraai committed Dec 8, 2019
1 parent e862c01 commit 4ea7bb8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/libcore/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1143,9 +1143,9 @@ pub unsafe trait Alloc {
where Self: Sized
{
match Layout::array::<T>(n) {
Ok(ref layout) if layout.size() > 0 => {
Ok(layout) if layout.size() > 0 => {
unsafe {
self.alloc(layout.clone()).map(|p| p.cast())
self.alloc(layout).map(|p| p.cast())
}
}
_ => Err(AllocErr),
Expand Down Expand Up @@ -1193,9 +1193,9 @@ pub unsafe trait Alloc {
where Self: Sized
{
match (Layout::array::<T>(n_old), Layout::array::<T>(n_new)) {
(Ok(ref k_old), Ok(ref k_new)) if k_old.size() > 0 && k_new.size() > 0 => {
(Ok(k_old), Ok(k_new)) if k_old.size() > 0 && k_new.size() > 0 => {
debug_assert!(k_old.align() == k_new.align());
self.realloc(ptr.cast(), k_old.clone(), k_new.size()).map(NonNull::cast)
self.realloc(ptr.cast(), k_old, k_new.size()).map(NonNull::cast)
}
_ => {
Err(AllocErr)
Expand Down Expand Up @@ -1227,8 +1227,8 @@ pub unsafe trait Alloc {
where Self: Sized
{
match Layout::array::<T>(n) {
Ok(ref k) if k.size() > 0 => {
Ok(self.dealloc(ptr.cast(), k.clone()))
Ok(k) if k.size() > 0 => {
Ok(self.dealloc(ptr.cast(), k))
}
_ => {
Err(AllocErr)
Expand Down

0 comments on commit 4ea7bb8

Please sign in to comment.