File tree 1 file changed +8
-4
lines changed
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 {
410
410
}
411
411
412
412
impl 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
+
414
418
unsafe {
415
419
let mut chunks = self . chunks . borrow_mut ( ) ;
416
420
let mut new_cap;
@@ -429,7 +433,7 @@ impl DroplessArena {
429
433
// Also ensure that this chunk can fit `additional`.
430
434
new_cap = cmp:: max ( additional, new_cap) ;
431
435
432
- let mut chunk = ArenaChunk :: new ( new_cap) ;
436
+ let mut chunk = ArenaChunk :: new ( align ( new_cap, PAGE ) ) ;
433
437
self . start . set ( chunk. start ( ) ) ;
434
438
435
439
// Align the end to DROPLESS_ALIGNMENT
@@ -445,8 +449,8 @@ impl DroplessArena {
445
449
#[ inline( never) ]
446
450
#[ cold]
447
451
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 ( )
450
454
}
451
455
452
456
#[ inline( never) ]
You can’t perform that action at this time.
0 commit comments