Fix a layout miscalculation in alloc::RawVec
This commit is contained in:
parent
9cdefd763b
commit
6027182328
@ -244,9 +244,7 @@ impl<T, A: Allocator> RawVec<T, A> {
|
|||||||
// We have an allocated chunk of memory, so we can bypass runtime
|
// We have an allocated chunk of memory, so we can bypass runtime
|
||||||
// checks to get our current layout.
|
// checks to get our current layout.
|
||||||
unsafe {
|
unsafe {
|
||||||
let align = mem::align_of::<T>();
|
let layout = Layout::array::<T>(self.cap).unwrap_unchecked();
|
||||||
let size = mem::size_of::<T>() * self.cap;
|
|
||||||
let layout = Layout::from_size_align_unchecked(size, align);
|
|
||||||
Some((self.ptr.cast().into(), layout))
|
Some((self.ptr.cast().into(), layout))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user