File tree 2 files changed +8
-8
lines changed
2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 10
10
11
11
#![ feature( allocator_api, nonnull) ]
12
12
13
- use std:: alloc:: { Heap , Alloc } ;
13
+ use std:: alloc:: { Alloc , Global } ;
14
14
15
15
fn main ( ) {
16
16
unsafe {
17
- let ptr = Heap . alloc_one :: < i32 > ( ) . unwrap_or_else ( |_| {
18
- Heap . oom ( )
17
+ let ptr = Global . alloc_one :: < i32 > ( ) . unwrap_or_else ( |_| {
18
+ Global . oom ( )
19
19
} ) ;
20
20
* ptr. as_ptr ( ) = 4 ;
21
21
assert_eq ! ( * ptr. as_ptr( ) , 4 ) ;
22
- Heap . dealloc_one ( ptr) ;
22
+ Global . dealloc_one ( ptr) ;
23
23
}
24
24
}
Original file line number Diff line number Diff line change 12
12
13
13
#![ feature( allocator_api) ]
14
14
15
- use std:: alloc:: { Alloc , Heap , Layout } ;
15
+ use std:: alloc:: { Alloc , Global , Layout } ;
16
16
use std:: ptr:: NonNull ;
17
17
18
18
struct arena ( ( ) ) ;
@@ -32,8 +32,8 @@ struct Ccx {
32
32
33
33
fn alloc < ' a > ( _bcx : & ' a arena ) -> & ' a Bcx < ' a > {
34
34
unsafe {
35
- let ptr = Heap . alloc ( Layout :: new :: < Bcx > ( ) )
36
- . unwrap_or_else ( |_| Heap . oom ( ) ) ;
35
+ let ptr = Global . alloc ( Layout :: new :: < Bcx > ( ) )
36
+ . unwrap_or_else ( |_| Global . oom ( ) ) ;
37
37
& * ( ptr. as_ptr ( ) as * const _ )
38
38
}
39
39
}
@@ -46,7 +46,7 @@ fn g(fcx : &Fcx) {
46
46
let bcx = Bcx { fcx : fcx } ;
47
47
let bcx2 = h ( & bcx) ;
48
48
unsafe {
49
- Heap . dealloc ( NonNull :: new_unchecked ( bcx2 as * const _ as * mut _ ) , Layout :: new :: < Bcx > ( ) ) ;
49
+ Global . dealloc ( NonNull :: new_unchecked ( bcx2 as * const _ as * mut _ ) , Layout :: new :: < Bcx > ( ) ) ;
50
50
}
51
51
}
52
52
You can’t perform that action at this time.
0 commit comments