=== modified file 'uspace/lib/c/generic/malloc.c'
|
|
|
683 | 683 | return NULL; |
684 | 684 | |
685 | 685 | size_t falign = lcm(align, BASE_ALIGN); |
686 | | size_t real_size = GROSS_SIZE(ALIGN_UP(size, falign)); |
| 686 | |
| 687 | /* |
| 688 | * This is minimal block size where we can allocate in. |
| 689 | * The alignment is checked in malloc_area(). |
| 690 | */ |
| 691 | size_t real_size = GROSS_SIZE(size); |
| 692 | /* |
| 693 | * When growing the heap, we need to allocate at least this much |
| 694 | * space. |
| 695 | * Generally, to allocate x bytes aligned at y, we need at least |
| 696 | * space x + y bytes. |
| 697 | * Here we add some extra space (through ALIGN_UP(..., BASE_ALIGN)) |
| 698 | * just to be on the safe side. |
| 699 | * Notice that we need to take care of all structures as growing |
| 700 | * the heap might bring a new AS area. |
| 701 | */ |
| 702 | size_t grow_size = ALIGN_UP(sizeof(heap_area_t), BASE_ALIGN) |
| 703 | + ALIGN_UP(sizeof(heap_block_head_t), BASE_ALIGN) |
| 704 | + falign |
| 705 | + ALIGN_UP(size, BASE_ALIGN) |
| 706 | + ALIGN_UP(sizeof(heap_block_foot_t), BASE_ALIGN); |
687 | 707 | |
688 | 708 | bool retry = false; |
689 | 709 | heap_block_head_t *split; |
… |
… |
|
716 | 736 | |
717 | 737 | if (!retry) { |
718 | 738 | /* Try to grow the heap space */ |
719 | | if (heap_grow(real_size)) { |
| 739 | if (heap_grow(grow_size)) { |
720 | 740 | retry = true; |
721 | 741 | goto loop; |
722 | 742 | } |