a few more &mut self -> self changes
This commit is contained in:
parent
985dff9e7e
commit
2b19b14cec
4 changed files with 21 additions and 21 deletions
|
@ -160,7 +160,7 @@ impl Global {
|
||||||
// SAFETY: Same as `AllocRef::grow`
|
// SAFETY: Same as `AllocRef::grow`
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn grow_impl(
|
unsafe fn grow_impl(
|
||||||
&mut self,
|
&self,
|
||||||
ptr: NonNull<u8>,
|
ptr: NonNull<u8>,
|
||||||
old_layout: Layout,
|
old_layout: Layout,
|
||||||
new_layout: Layout,
|
new_layout: Layout,
|
||||||
|
@ -228,7 +228,7 @@ unsafe impl AllocRef for Global {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn grow(
|
unsafe fn grow(
|
||||||
&mut self,
|
&self,
|
||||||
ptr: NonNull<u8>,
|
ptr: NonNull<u8>,
|
||||||
old_layout: Layout,
|
old_layout: Layout,
|
||||||
new_layout: Layout,
|
new_layout: Layout,
|
||||||
|
@ -239,7 +239,7 @@ unsafe impl AllocRef for Global {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn grow_zeroed(
|
unsafe fn grow_zeroed(
|
||||||
&mut self,
|
&self,
|
||||||
ptr: NonNull<u8>,
|
ptr: NonNull<u8>,
|
||||||
old_layout: Layout,
|
old_layout: Layout,
|
||||||
new_layout: Layout,
|
new_layout: Layout,
|
||||||
|
@ -250,7 +250,7 @@ unsafe impl AllocRef for Global {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn shrink(
|
unsafe fn shrink(
|
||||||
&mut self,
|
&self,
|
||||||
ptr: NonNull<u8>,
|
ptr: NonNull<u8>,
|
||||||
old_layout: Layout,
|
old_layout: Layout,
|
||||||
new_layout: Layout,
|
new_layout: Layout,
|
||||||
|
|
|
@ -183,7 +183,7 @@ pub unsafe trait AllocRef {
|
||||||
///
|
///
|
||||||
/// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
|
/// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
|
||||||
unsafe fn grow(
|
unsafe fn grow(
|
||||||
&mut self,
|
&self,
|
||||||
ptr: NonNull<u8>,
|
ptr: NonNull<u8>,
|
||||||
old_layout: Layout,
|
old_layout: Layout,
|
||||||
new_layout: Layout,
|
new_layout: Layout,
|
||||||
|
@ -244,7 +244,7 @@ pub unsafe trait AllocRef {
|
||||||
///
|
///
|
||||||
/// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
|
/// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
|
||||||
unsafe fn grow_zeroed(
|
unsafe fn grow_zeroed(
|
||||||
&mut self,
|
&self,
|
||||||
ptr: NonNull<u8>,
|
ptr: NonNull<u8>,
|
||||||
old_layout: Layout,
|
old_layout: Layout,
|
||||||
new_layout: Layout,
|
new_layout: Layout,
|
||||||
|
@ -308,7 +308,7 @@ pub unsafe trait AllocRef {
|
||||||
///
|
///
|
||||||
/// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
|
/// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
|
||||||
unsafe fn shrink(
|
unsafe fn shrink(
|
||||||
&mut self,
|
&self,
|
||||||
ptr: NonNull<u8>,
|
ptr: NonNull<u8>,
|
||||||
old_layout: Layout,
|
old_layout: Layout,
|
||||||
new_layout: Layout,
|
new_layout: Layout,
|
||||||
|
@ -337,13 +337,13 @@ pub unsafe trait AllocRef {
|
||||||
///
|
///
|
||||||
/// The returned adaptor also implements `AllocRef` and will simply borrow this.
|
/// The returned adaptor also implements `AllocRef` and will simply borrow this.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn by_ref(&mut self) -> &mut Self {
|
fn by_ref(&mut self) -> &Self {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "allocator_api", issue = "32838")]
|
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||||
unsafe impl<A> AllocRef for &mut A
|
unsafe impl<A> AllocRef for &A
|
||||||
where
|
where
|
||||||
A: AllocRef + ?Sized,
|
A: AllocRef + ?Sized,
|
||||||
{
|
{
|
||||||
|
@ -365,7 +365,7 @@ where
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn grow(
|
unsafe fn grow(
|
||||||
&mut self,
|
&self,
|
||||||
ptr: NonNull<u8>,
|
ptr: NonNull<u8>,
|
||||||
old_layout: Layout,
|
old_layout: Layout,
|
||||||
new_layout: Layout,
|
new_layout: Layout,
|
||||||
|
@ -376,7 +376,7 @@ where
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn grow_zeroed(
|
unsafe fn grow_zeroed(
|
||||||
&mut self,
|
&self,
|
||||||
ptr: NonNull<u8>,
|
ptr: NonNull<u8>,
|
||||||
old_layout: Layout,
|
old_layout: Layout,
|
||||||
new_layout: Layout,
|
new_layout: Layout,
|
||||||
|
@ -387,7 +387,7 @@ where
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn shrink(
|
unsafe fn shrink(
|
||||||
&mut self,
|
&self,
|
||||||
ptr: NonNull<u8>,
|
ptr: NonNull<u8>,
|
||||||
old_layout: Layout,
|
old_layout: Layout,
|
||||||
new_layout: Layout,
|
new_layout: Layout,
|
||||||
|
|
|
@ -152,7 +152,7 @@ impl System {
|
||||||
// SAFETY: Same as `AllocRef::grow`
|
// SAFETY: Same as `AllocRef::grow`
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn grow_impl(
|
unsafe fn grow_impl(
|
||||||
&mut self,
|
&self,
|
||||||
ptr: NonNull<u8>,
|
ptr: NonNull<u8>,
|
||||||
old_layout: Layout,
|
old_layout: Layout,
|
||||||
new_layout: Layout,
|
new_layout: Layout,
|
||||||
|
@ -190,7 +190,7 @@ impl System {
|
||||||
old_size => unsafe {
|
old_size => unsafe {
|
||||||
let new_ptr = self.alloc_impl(new_layout, zeroed)?;
|
let new_ptr = self.alloc_impl(new_layout, zeroed)?;
|
||||||
ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), old_size);
|
ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), old_size);
|
||||||
self.dealloc(ptr, old_layout);
|
AllocRef::dealloc(&self, ptr, old_layout);
|
||||||
Ok(new_ptr)
|
Ok(new_ptr)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ unsafe impl AllocRef for System {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn grow(
|
unsafe fn grow(
|
||||||
&mut self,
|
&self,
|
||||||
ptr: NonNull<u8>,
|
ptr: NonNull<u8>,
|
||||||
old_layout: Layout,
|
old_layout: Layout,
|
||||||
new_layout: Layout,
|
new_layout: Layout,
|
||||||
|
@ -233,7 +233,7 @@ unsafe impl AllocRef for System {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn grow_zeroed(
|
unsafe fn grow_zeroed(
|
||||||
&mut self,
|
&self,
|
||||||
ptr: NonNull<u8>,
|
ptr: NonNull<u8>,
|
||||||
old_layout: Layout,
|
old_layout: Layout,
|
||||||
new_layout: Layout,
|
new_layout: Layout,
|
||||||
|
@ -244,7 +244,7 @@ unsafe impl AllocRef for System {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn shrink(
|
unsafe fn shrink(
|
||||||
&mut self,
|
&self,
|
||||||
ptr: NonNull<u8>,
|
ptr: NonNull<u8>,
|
||||||
old_layout: Layout,
|
old_layout: Layout,
|
||||||
new_layout: Layout,
|
new_layout: Layout,
|
||||||
|
@ -257,7 +257,7 @@ unsafe impl AllocRef for System {
|
||||||
match new_layout.size() {
|
match new_layout.size() {
|
||||||
// SAFETY: conditions must be upheld by the caller
|
// SAFETY: conditions must be upheld by the caller
|
||||||
0 => unsafe {
|
0 => unsafe {
|
||||||
self.dealloc(ptr, old_layout);
|
AllocRef::dealloc(&self, ptr, old_layout);
|
||||||
Ok(NonNull::slice_from_raw_parts(new_layout.dangling(), 0))
|
Ok(NonNull::slice_from_raw_parts(new_layout.dangling(), 0))
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -277,9 +277,9 @@ unsafe impl AllocRef for System {
|
||||||
// `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract
|
// `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract
|
||||||
// for `dealloc` must be upheld by the caller.
|
// for `dealloc` must be upheld by the caller.
|
||||||
new_size => unsafe {
|
new_size => unsafe {
|
||||||
let new_ptr = self.alloc(new_layout)?;
|
let new_ptr = AllocRef::alloc(&self, new_layout)?;
|
||||||
ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), new_size);
|
ptr::copy_nonoverlapping(ptr.as_ptr(), new_ptr.as_mut_ptr(), new_size);
|
||||||
self.dealloc(ptr, old_layout);
|
AllocRef::dealloc(&self, ptr, old_layout);
|
||||||
Ok(new_ptr)
|
Ok(new_ptr)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ struct A;
|
||||||
unsafe impl alloc::GlobalAlloc for A {
|
unsafe impl alloc::GlobalAlloc for A {
|
||||||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||||
HITS.fetch_add(1, Ordering::SeqCst);
|
HITS.fetch_add(1, Ordering::SeqCst);
|
||||||
AllocRef::alloc(&System, layout).unwrap().as_mut_ptr()
|
alloc::GlobalAlloc::alloc(&System, layout)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
|
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue