| 676 | } |
| 677 | |
| 678 | void fxGrowSlots(txMachine* the, txSize theCount) |
| 679 | { |
| 680 | txSlot* aHeap; |
| 681 | txSlot* aSlot; |
| 682 | |
| 683 | aHeap = fxAllocateSlots(the, theCount); |
| 684 | if (!aHeap) { |
| 685 | fxReport(the, "# Slot allocation: failed for %ld bytes\n", theCount * sizeof(txSlot)); |
| 686 | fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT); |
| 687 | } |
| 688 | if ((void *)-1 == aHeap) |
| 689 | return; |
| 690 | |
| 691 | if (the->firstHeap && the->growHeapDirection) { |
| 692 | if (the->growHeapDirection > 0) { |
| 693 | the->firstHeap->value.reference = aHeap + theCount; |
| 694 | the->maximumHeapCount += theCount; |
| 695 | theCount -= 1; |
| 696 | aSlot = aHeap; |
| 697 | } |
| 698 | else { |
| 699 | *aHeap = *(the->firstHeap); |
| 700 | the->maximumHeapCount += theCount; |
| 701 | theCount -= 1; |
| 702 | the->firstHeap = aHeap; |
| 703 | aSlot = aHeap + 1; |
| 704 | } |
| 705 | } |
| 706 | else { |
| 707 | the->maximumHeapCount += theCount - 1; |
| 708 | aHeap->next = the->firstHeap; |
| 709 | aHeap->ID = 0; |
| 710 | aHeap->flag = 0; |
| 711 | aHeap->kind = 0; |
| 712 | aHeap->value.reference = aHeap + theCount; |
| 713 | theCount -= 2; |
| 714 | the->firstHeap = aHeap; |
| 715 | aSlot = aHeap + 1; |
| 716 | } |
| 717 | while (theCount--) { |
| 718 | txSlot* next = aSlot + 1; |
| 719 | aSlot->next = next; |
| 720 | aSlot->flag = XS_NO_FLAG; |
| 721 | aSlot->kind = XS_UNDEFINED_KIND; |
| 722 | #if mxPoisonSlots |
| 723 | ASAN_POISON_MEMORY_REGION(&aSlot->value, sizeof(aSlot->value)); |
| 724 | #endif |
| 725 | aSlot = next; |
| 726 | } |
| 727 | aSlot->next = the->freeHeap; |
| 728 | aSlot->flag = XS_NO_FLAG; |
| 729 | aSlot->kind = XS_UNDEFINED_KIND; |
| 730 | #if mxPoisonSlots |
| 731 | ASAN_POISON_MEMORY_REGION(&aSlot->value, sizeof(aSlot->value)); |
| 732 | #endif |
| 733 | the->freeHeap = aHeap + 1; |
| 734 | the->collectFlag &= ~XS_TRASHING_SLOTS_FLAG; |
| 735 | #if mxReport |
no test coverage detected