File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,13 @@ unsafe fn test_triangle() -> bool {
5656
5757 ret
5858 }
59+ unsafe fn deallocate ( ptr : * mut u8 , size : uint , align : uint ) {
60+ if PRINT { println ! ( "deallocate(ptr=0x{:010x} size={:u} align={:u})" ,
61+ ptr as uint, size, align) ;
62+ }
63+
64+ heap:: deallocate ( ptr, size, align) ;
65+ }
5966 unsafe fn reallocate ( ptr : * mut u8 , size : uint , align : uint ,
6067 old_size : uint ) -> * mut u8 {
6168 if PRINT {
@@ -95,10 +102,16 @@ unsafe fn test_triangle() -> bool {
95102 }
96103
97104 sanity_check ( ascend. as_slice ( ) ) ;
98- test_1 ( ascend) ;
99- test_2 ( ascend) ;
100- test_3 ( ascend) ;
101- test_4 ( ascend) ;
105+ test_1 ( ascend) ; // triangle -> square
106+ test_2 ( ascend) ; // square -> triangle
107+ test_3 ( ascend) ; // triangle -> square
108+ test_4 ( ascend) ; // square -> triangle
109+
110+ for i in range ( 0 u, COUNT / 2 ) {
111+ let size = idx_to_size ( i) ;
112+ deallocate ( ascend[ 2 * i] , size, ALIGN ) ;
113+ deallocate ( ascend[ 2 * i+1 ] , size, ALIGN ) ;
114+ }
102115
103116 return true ;
104117
You can’t perform that action at this time.
0 commit comments