File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -184,6 +184,8 @@ impl Allocator<'static> {
184184
185185impl Allocator < ' _ > {
186186 fn allocate_layout ( & self , layout : Layout ) -> * mut c_void {
187+ assert ! ( layout. align( ) <= ALIGN . into( ) ) ;
188+
187189 // Special case for the Rust `alloc` backed allocator
188190 #[ cfg( feature = "rust-allocator" ) ]
189191 if self . zalloc == Allocator :: RUST . zalloc {
@@ -268,6 +270,8 @@ impl Allocator<'_> {
268270 }
269271
270272 fn allocate_layout_zeroed ( & self , layout : Layout ) -> * mut c_void {
273+ assert ! ( layout. align( ) <= ALIGN . into( ) ) ;
274+
271275 #[ cfg( feature = "rust-allocator" ) ]
272276 if self . zalloc == Allocator :: RUST . zalloc {
273277 let ptr = unsafe { zalloc_rust_calloc ( self . opaque , layout. size ( ) as _ , 1 ) } ;
@@ -313,8 +317,7 @@ impl Allocator<'_> {
313317 }
314318
315319 pub fn allocate_zeroed_buffer ( & self , len : usize ) -> Option < NonNull < u8 > > {
316- // internally, we want to align allocations to 64 bytes (in part for SIMD reasons)
317- let layout = Layout :: from_size_align ( len, ALIGN . into ( ) ) . unwrap ( ) ;
320+ let layout = Layout :: array :: < u8 > ( len) . ok ( ) ?;
318321 NonNull :: new ( self . allocate_layout_zeroed ( layout) . cast ( ) )
319322 }
320323
You can’t perform that action at this time.
0 commit comments