@@ -133,7 +133,7 @@ pub struct System;
133
133
134
134
impl System {
135
135
#[ inline]
136
- fn alloc_impl ( & mut self , layout : Layout , zeroed : bool ) -> Result < NonNull < [ u8 ] > , AllocErr > {
136
+ fn alloc_impl ( & self , layout : Layout , zeroed : bool ) -> Result < NonNull < [ u8 ] > , AllocErr > {
137
137
match layout. size ( ) {
138
138
0 => Ok ( NonNull :: slice_from_raw_parts ( layout. dangling ( ) , 0 ) ) ,
139
139
// SAFETY: `layout` is non-zero in size,
@@ -152,7 +152,7 @@ impl System {
152
152
// SAFETY: Same as `AllocRef::grow`
153
153
#[ inline]
154
154
unsafe fn grow_impl (
155
- & mut self ,
155
+ & self ,
156
156
ptr : NonNull < u8 > ,
157
157
old_layout : Layout ,
158
158
new_layout : Layout ,
@@ -190,7 +190,7 @@ impl System {
190
190
old_size => unsafe {
191
191
let new_ptr = self . alloc_impl ( new_layout, zeroed) ?;
192
192
ptr:: copy_nonoverlapping ( ptr. as_ptr ( ) , new_ptr. as_mut_ptr ( ) , old_size) ;
193
- self . dealloc ( ptr, old_layout) ;
193
+ AllocRef :: dealloc ( & self , ptr, old_layout) ;
194
194
Ok ( new_ptr)
195
195
} ,
196
196
}
@@ -202,17 +202,17 @@ impl System {
202
202
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
203
203
unsafe impl AllocRef for System {
204
204
#[ inline]
205
- fn alloc ( & mut self , layout : Layout ) -> Result < NonNull < [ u8 ] > , AllocErr > {
205
+ fn alloc ( & self , layout : Layout ) -> Result < NonNull < [ u8 ] > , AllocErr > {
206
206
self . alloc_impl ( layout, false )
207
207
}
208
208
209
209
#[ inline]
210
- fn alloc_zeroed ( & mut self , layout : Layout ) -> Result < NonNull < [ u8 ] > , AllocErr > {
210
+ fn alloc_zeroed ( & self , layout : Layout ) -> Result < NonNull < [ u8 ] > , AllocErr > {
211
211
self . alloc_impl ( layout, true )
212
212
}
213
213
214
214
#[ inline]
215
- unsafe fn dealloc ( & mut self , ptr : NonNull < u8 > , layout : Layout ) {
215
+ unsafe fn dealloc ( & self , ptr : NonNull < u8 > , layout : Layout ) {
216
216
if layout. size ( ) != 0 {
217
217
// SAFETY: `layout` is non-zero in size,
218
218
// other conditions must be upheld by the caller
@@ -222,7 +222,7 @@ unsafe impl AllocRef for System {
222
222
223
223
#[ inline]
224
224
unsafe fn grow (
225
- & mut self ,
225
+ & self ,
226
226
ptr : NonNull < u8 > ,
227
227
old_layout : Layout ,
228
228
new_layout : Layout ,
@@ -233,7 +233,7 @@ unsafe impl AllocRef for System {
233
233
234
234
#[ inline]
235
235
unsafe fn grow_zeroed (
236
- & mut self ,
236
+ & self ,
237
237
ptr : NonNull < u8 > ,
238
238
old_layout : Layout ,
239
239
new_layout : Layout ,
@@ -244,7 +244,7 @@ unsafe impl AllocRef for System {
244
244
245
245
#[ inline]
246
246
unsafe fn shrink (
247
- & mut self ,
247
+ & self ,
248
248
ptr : NonNull < u8 > ,
249
249
old_layout : Layout ,
250
250
new_layout : Layout ,
@@ -257,7 +257,7 @@ unsafe impl AllocRef for System {
257
257
match new_layout. size ( ) {
258
258
// SAFETY: conditions must be upheld by the caller
259
259
0 => unsafe {
260
- self . dealloc ( ptr, old_layout) ;
260
+ AllocRef :: dealloc ( & self , ptr, old_layout) ;
261
261
Ok ( NonNull :: slice_from_raw_parts ( new_layout. dangling ( ) , 0 ) )
262
262
} ,
263
263
@@ -277,9 +277,9 @@ unsafe impl AllocRef for System {
277
277
// `new_ptr`. Thus, the call to `copy_nonoverlapping` is safe. The safety contract
278
278
// for `dealloc` must be upheld by the caller.
279
279
new_size => unsafe {
280
- let new_ptr = self . alloc ( new_layout) ?;
280
+ let new_ptr = AllocRef :: alloc ( & self , new_layout) ?;
281
281
ptr:: copy_nonoverlapping ( ptr. as_ptr ( ) , new_ptr. as_mut_ptr ( ) , new_size) ;
282
- self . dealloc ( ptr, old_layout) ;
282
+ AllocRef :: dealloc ( & self , ptr, old_layout) ;
283
283
Ok ( new_ptr)
284
284
} ,
285
285
}
0 commit comments