@@ -502,9 +502,10 @@ fn extend_fragmented_heap() {
502
502
/// the hole write would result in an out of bounds write.
503
503
#[ test]
504
504
fn 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 ] ;
506
507
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 ) ;
508
509
heap. try_extend ( 1 )
509
510
} ;
510
511
assert_eq ! ( result, Err ( ExtendError :: SizeTooSmall ) )
@@ -513,9 +514,10 @@ fn small_heap_extension() {
513
514
/// Ensures that `Heap::extend` fails for sizes that are not a multiple of the hole size.
514
515
#[ test]
515
516
fn 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 ] ;
517
519
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 ) ;
519
521
heap. try_extend ( 17 )
520
522
} ;
521
523
assert_eq ! ( result, Err ( ExtendError :: OddSize ) )
@@ -539,9 +541,10 @@ fn extend_empty() {
539
541
/// only works if the top pointer is sufficiently aligned.
540
542
#[ test]
541
543
fn 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 ] ;
543
546
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 ) ;
545
548
heap. try_extend ( 16 )
546
549
} ;
547
550
assert_eq ! ( result, Err ( ExtendError :: OddHeapSize ) )
0 commit comments