File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -410,7 +410,11 @@ impl Default for DroplessArena {
410410}
411411
412412impl DroplessArena {
413- fn grow ( & self , additional : usize ) {
413+ fn grow ( & self , layout : Layout ) {
414+ // Add some padding so we can align `self.end` while
415+ // stilling fitting in a `layout` allocation.
416+ let additional = layout. size ( ) + cmp:: max ( DROPLESS_ALIGNMENT , layout. align ( ) ) - 1 ;
417+
414418 unsafe {
415419 let mut chunks = self . chunks . borrow_mut ( ) ;
416420 let mut new_cap;
@@ -429,7 +433,7 @@ impl DroplessArena {
429433 // Also ensure that this chunk can fit `additional`.
430434 new_cap = cmp:: max ( additional, new_cap) ;
431435
432- let mut chunk = ArenaChunk :: new ( new_cap) ;
436+ let mut chunk = ArenaChunk :: new ( align ( new_cap, PAGE ) ) ;
433437 self . start . set ( chunk. start ( ) ) ;
434438
435439 // Align the end to DROPLESS_ALIGNMENT
@@ -445,8 +449,8 @@ impl DroplessArena {
445449 #[ inline( never) ]
446450 #[ cold]
447451 fn grow_and_alloc_raw ( & self , layout : Layout ) -> * mut u8 {
448- self . grow ( layout. size ( ) ) ;
449- self . alloc_raw ( layout)
452+ self . grow ( layout) ;
453+ self . alloc_raw_without_grow ( layout) . unwrap ( )
450454 }
451455
452456 #[ inline( never) ]
You can’t perform that action at this time.
0 commit comments