1 use std::alloc::{Global, Alloc, Layout, System};
5 fn alloc_system_overaligned_request() {
6 check_overalign_requests(System)
10 fn std_heap_overaligned_request() {
11 check_overalign_requests(Global)
14 fn check_overalign_requests<T: Alloc>(mut allocator: T) {
16 let align = 16; // greater than size
19 let pointers: Vec<_> = (0..iterations).map(|_| {
20 allocator.alloc(Layout::from_size_align(size, align).unwrap()).unwrap()
22 for &ptr in &pointers {
23 assert_eq!((ptr.as_ptr() as usize) % align, 0,
24 "Got a pointer less aligned than requested")
28 for &ptr in &pointers {
29 allocator.dealloc(ptr, Layout::from_size_align(size, align).unwrap())