mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
Apply suggestions from code review
Co-authored-by: nikomatsakis <niko@alum.mit.edu>
This commit is contained in:
+11
-9
@@ -215,14 +215,16 @@ unsafe fn grow(
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,11 +257,11 @@ unsafe fn shrink(
|
||||
}
|
||||
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 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user