File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,15 @@ pub struct HoleList {
1414}
1515
1616impl HoleList {
17+ pub const fn empty ( ) -> HoleList {
18+ HoleList {
19+ first : Hole {
20+ size : 0 ,
21+ next : None ,
22+ } ,
23+ }
24+ }
25+
1726 pub unsafe fn new ( ptr : * mut Hole , size : usize ) -> HoleList {
1827 assert ! ( size_of:: <Hole >( ) == Self :: min_size( ) ) ;
1928
Original file line number Diff line number Diff line change 11#![ feature( unique) ]
2+ #![ feature( const_fn) ]
23#![ no_std]
34
45#[ cfg( test) ]
@@ -16,6 +17,14 @@ pub struct Heap {
1617}
1718
1819impl Heap {
20+ pub const fn empty ( ) -> Heap {
21+ Heap {
22+ top : 0 ,
23+ bottom : 0 ,
24+ holes : HoleList :: empty ( ) ,
25+ }
26+ }
27+
1928 pub fn new ( heap_bottom : usize , heap_top : usize ) -> Heap {
2029 Heap {
2130 bottom : heap_bottom,
@@ -38,11 +47,11 @@ impl Heap {
3847 }
3948 self . holes . deallocate ( ptr, size) ;
4049 }
41-
50+
4251 pub fn bottom ( & self ) -> usize {
4352 self . bottom
4453 }
45-
54+
4655 pub fn top ( & self ) -> usize {
4756 self . top
4857 }
You can’t perform that action at this time.
0 commit comments