diff options
| author | Tim Diekmann <tim.diekmann@3dvision.de> | 2020-03-29 01:47:05 +0100 | 
|---|---|---|
| committer | Tim Diekmann <tim.diekmann@3dvision.de> | 2020-03-29 01:47:05 +0100 | 
| commit | 3ade8ae6608a9d371580e5e8d68c26a4e3e897fb (patch) | |
| tree | 49607964c87f5f8fe647160c42b178226e2b570a /src/libstd/alloc.rs | |
| parent | bf6a46db3129b0bf31dc67f06af2e52ece52701a (diff) | |
| download | rust-3ade8ae6608a9d371580e5e8d68c26a4e3e897fb.tar.gz rust-3ade8ae6608a9d371580e5e8d68c26a4e3e897fb.zip | |
Implement `init` and `init_offset` on `AllocInit` and mark it unsafe
Diffstat (limited to 'src/libstd/alloc.rs')
| -rw-r--r-- | src/libstd/alloc.rs | 8 | 
1 files changed, 4 insertions, 4 deletions
| diff --git a/src/libstd/alloc.rs b/src/libstd/alloc.rs index 843c46775af..8df4666c536 100644 --- a/src/libstd/alloc.rs +++ b/src/libstd/alloc.rs @@ -188,12 +188,12 @@ unsafe impl AllocRef for System { self.alloc(new_layout, init) } ReallocPlacement::MayMove => { - // `realloc` probably checks for `new_size > old_size` or something similar. + // `realloc` probably checks for `new_size > size` or something similar. intrinsics::assume(new_size > size); let ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size); - let mut memory = + let memory = MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size }; - memory.init_offset(init, size); + init.init_offset(memory, size); Ok(memory) } } @@ -224,7 +224,7 @@ unsafe impl AllocRef for System { Ok(MemoryBlock { ptr: layout.dangling(), size: 0 }) } ReallocPlacement::MayMove => { - // `realloc` probably checks for `new_size < old_size` or something similar. + // `realloc` probably checks for `new_size < size` or something similar. intrinsics::assume(new_size < size); let ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size); Ok(MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size }) | 
