@@ -502,9 +502,10 @@ fn extend_fragmented_heap() {
502502/// the hole write would result in an out of bounds write.
503503#[ test]
504504fn small_heap_extension ( ) {
505- static mut HEAP : [ u8 ; 33 ] = [ 0 ; 33 ] ;
505+ // define an array of `u64` instead of `u8` for alignment
506+ static mut HEAP : [ u64 ; 5 ] = [ 0 ; 5 ] ;
506507 let result = unsafe {
507- let mut heap = Heap :: new ( HEAP . as_mut_ptr ( ) , 32 ) ;
508+ let mut heap = Heap :: new ( HEAP . as_mut_ptr ( ) . cast ( ) , 32 ) ;
508509 heap. try_extend ( 1 )
509510 } ;
510511 assert_eq ! ( result, Err ( ExtendError :: SizeTooSmall ) )
@@ -513,9 +514,10 @@ fn small_heap_extension() {
513514/// Ensures that `Heap::extend` fails for sizes that are not a multiple of the hole size.
514515#[ test]
515516fn oddly_sized_heap_extension ( ) {
516- static mut HEAP : [ u8 ; 33 ] = [ 0 ; 33 ] ;
517+ // define an array of `u64` instead of `u8` for alignment
518+ static mut HEAP : [ u64 ; 5 ] = [ 0 ; 5 ] ;
517519 let result = unsafe {
518- let mut heap = Heap :: new ( HEAP . as_mut_ptr ( ) , 16 ) ;
520+ let mut heap = Heap :: new ( HEAP . as_mut_ptr ( ) . cast ( ) , 16 ) ;
519521 heap. try_extend ( 17 )
520522 } ;
521523 assert_eq ! ( result, Err ( ExtendError :: OddSize ) )
@@ -539,9 +541,10 @@ fn extend_empty() {
539541/// only works if the top pointer is sufficiently aligned.
540542#[ test]
541543fn extend_odd_size ( ) {
542- static mut HEAP : [ u8 ; 33 ] = [ 0 ; 33 ] ;
544+ // define an array of `u64` instead of `u8` for alignment
545+ static mut HEAP : [ u64 ; 5 ] = [ 0 ; 5 ] ;
543546 let result = unsafe {
544- let mut heap = Heap :: new ( HEAP . as_mut_ptr ( ) , 17 ) ;
547+ let mut heap = Heap :: new ( HEAP . as_mut_ptr ( ) . cast ( ) , 17 ) ;
545548 heap. try_extend ( 16 )
546549 } ;
547550 assert_eq ! ( result, Err ( ExtendError :: OddHeapSize ) )
0 commit comments