File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -17,12 +17,13 @@ impl HoleList {
1717 }
1818 }
1919
20- pub unsafe fn new ( ptr : * mut Hole , size : usize ) -> HoleList {
20+ pub unsafe fn new ( hole_addr : usize , hole_size : usize ) -> HoleList {
2121 assert ! ( size_of:: <Hole >( ) == Self :: min_size( ) ) ;
2222
23+ let ptr = hole_addr as * mut Hole ;
2324 mem:: forget ( mem:: replace ( & mut * ptr,
2425 Hole {
25- size : size ,
26+ size : hole_size ,
2627 next : None ,
2728 } ) ) ;
2829
@@ -48,10 +49,7 @@ impl HoleList {
4849 } )
4950 }
5051
51- pub fn deallocate ( & mut self , ptr : * mut u8 , size : usize ) {
52- println ! ( "deallocate {:p} ({} bytes)" , ptr, size) ;
53- assert ! ( size >= Self :: min_size( ) ) ;
54-
52+ pub unsafe fn deallocate ( & mut self , ptr : * mut u8 , size : usize ) {
5553 deallocate ( & mut self . first , ptr as usize , size)
5654 }
5755
Original file line number Diff line number Diff line change @@ -25,11 +25,11 @@ impl Heap {
2525 }
2626 }
2727
28- pub fn new ( heap_bottom : usize , heap_top : usize ) -> Heap {
28+ pub unsafe fn new ( heap_bottom : usize , heap_top : usize ) -> Heap {
2929 Heap {
3030 bottom : heap_bottom,
3131 top : heap_top,
32- holes : unsafe { HoleList :: new ( heap_bottom as * mut _ , heap_top - heap_bottom) } ,
32+ holes : HoleList :: new ( heap_bottom, heap_top - heap_bottom) ,
3333 }
3434 }
3535
@@ -41,7 +41,7 @@ impl Heap {
4141 self . holes . allocate_first_fit ( size, align)
4242 }
4343
44- pub fn deallocate ( & mut self , ptr : * mut u8 , mut size : usize , _align : usize ) {
44+ pub unsafe fn deallocate ( & mut self , ptr : * mut u8 , mut size : usize , _align : usize ) {
4545 if size < HoleList :: min_size ( ) {
4646 size = HoleList :: min_size ( ) ;
4747 }
You can’t perform that action at this time.
0 commit comments