Apply suggestions from code review
Co-authored-by: nikomatsakis <niko@alum.mit.edu>
This commit is contained in:
parent
39e29ce4d0
commit
7b6398657c
@ -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 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user