3 use std::alloc::{Global, Alloc, Layout, System};
7 fn alloc_system_overaligned_request() {
8 check_overalign_requests(System)
12 fn std_heap_overaligned_request() {
13 check_overalign_requests(Global)
16 fn check_overalign_requests<T: Alloc>(mut allocator: T) {
18 let align = 16; // greater than size
21 let pointers: Vec<_> = (0..iterations).map(|_| {
22 allocator.alloc(Layout::from_size_align(size, align).unwrap()).unwrap()
24 for &ptr in &pointers {
25 assert_eq!((ptr.as_ptr() as usize) % align, 0,
26 "Got a pointer less aligned than requested")
30 for &ptr in &pointers {
31 allocator.dealloc(ptr, Layout::from_size_align(size, align).unwrap())