Make grow_impl
unsafe
This commit is contained in:
parent
66a651244e
commit
63d241a7b7
2 changed files with 12 additions and 6 deletions
|
@ -175,8 +175,9 @@ impl Global {
|
|||
}
|
||||
}
|
||||
|
||||
// Safety: Same as `AllocRef::grow`
|
||||
#[inline]
|
||||
fn grow_impl(
|
||||
unsafe fn grow_impl(
|
||||
&mut self,
|
||||
ptr: NonNull<u8>,
|
||||
layout: Layout,
|
||||
|
@ -241,7 +242,8 @@ unsafe impl AllocRef for Global {
|
|||
layout: Layout,
|
||||
new_size: usize,
|
||||
) -> Result<NonNull<[u8]>, AllocErr> {
|
||||
self.grow_impl(ptr, layout, new_size, false)
|
||||
// SAFETY: all conditions must be upheld by the caller
|
||||
unsafe { self.grow_impl(ptr, layout, new_size, false) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -251,7 +253,8 @@ unsafe impl AllocRef for Global {
|
|||
layout: Layout,
|
||||
new_size: usize,
|
||||
) -> Result<NonNull<[u8]>, AllocErr> {
|
||||
self.grow_impl(ptr, layout, new_size, true)
|
||||
// SAFETY: all conditions must be upheld by the caller
|
||||
unsafe { self.grow_impl(ptr, layout, new_size, true) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -149,8 +149,9 @@ impl System {
|
|||
}
|
||||
}
|
||||
|
||||
// Safety: Same as `AllocRef::grow`
|
||||
#[inline]
|
||||
fn grow_impl(
|
||||
unsafe fn grow_impl(
|
||||
&mut self,
|
||||
ptr: NonNull<u8>,
|
||||
layout: Layout,
|
||||
|
@ -217,7 +218,8 @@ unsafe impl AllocRef for System {
|
|||
layout: Layout,
|
||||
new_size: usize,
|
||||
) -> Result<NonNull<[u8]>, AllocErr> {
|
||||
self.grow_impl(ptr, layout, new_size, false)
|
||||
// SAFETY: all conditions must be upheld by the caller
|
||||
unsafe { self.grow_impl(ptr, layout, new_size, false) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -227,7 +229,8 @@ unsafe impl AllocRef for System {
|
|||
layout: Layout,
|
||||
new_size: usize,
|
||||
) -> Result<NonNull<[u8]>, AllocErr> {
|
||||
self.grow_impl(ptr, layout, new_size, true)
|
||||
// SAFETY: all conditions must be upheld by the caller
|
||||
unsafe { self.grow_impl(ptr, layout, new_size, true) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Reference in a new issue