diff options
| author | Tim Diekmann <tim.diekmann@3dvision.de> | 2020-08-18 15:22:10 +0200 |
|---|---|---|
| committer | Tim Diekmann <tim.diekmann@3dvision.de> | 2020-08-18 15:22:10 +0200 |
| commit | 63d241a7b78f129477d980bf5a6baa818f47b4f8 (patch) | |
| tree | 5e3a2948163f08525aeba2f731cc1988d95c6551 /library/std/src/alloc.rs | |
| parent | 66a651244ee810d9027c0ff2266a097d9aa06b59 (diff) | |
| download | rust-63d241a7b78f129477d980bf5a6baa818f47b4f8.tar.gz rust-63d241a7b78f129477d980bf5a6baa818f47b4f8.zip | |
Make `grow_impl` unsafe
Diffstat (limited to 'library/std/src/alloc.rs')
| -rw-r--r-- | library/std/src/alloc.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs index bc895640fd2..b4009c86419 100644 --- a/library/std/src/alloc.rs +++ b/library/std/src/alloc.rs @@ -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] |
