Code: Select all
void *HeapAlloc(unsigned size, bool pageAlign, Heap *heap)
{
/* Size including the header and footer. */
unsigned RealSize = size + sizeof(HeapHeader) + sizeof(HeapFooter);
int i = GetSmallestHole(RealSize, pageAlign, heap);
/* No hole found? */
if(i == -1)
{
unsigned OldLength = heap->EndAddress - heap->StartAddress;
unsigned OldEndAddress = heap->EndAddress;
/* Make the heap larger, return 0 if failed to prevent going past the maximum address. */
if(ExpandHeap(heap, OldLength + RealSize) == -1)
return 0;
//...
Code: Select all
static int ExpandHeap(Heap *heap, unsigned newSize)
{
//...
/* Make sure there are pages present at the new addresses (start at the heap ending address). */
for(unsigned i(heap->EndAddress); i < heap->StartAddress + newSize; i += HEAP_PAGESIZE)
AllocateFrame(GetPage(i, true, KernelDir), heap->Supervisor? 1 : 0, heap->ReadOnly? 0 : 1);
//...
}
Code: Select all
directory->PageTables[TableID] = (PageTable *) MM->AllocAlignGetPhys(sizeof(PageTable), &PhysAddr);
Am I making a mistake somewhere, or is this an infinite loop? Setting debug log prints only acknowledges what I'm thinking.
Thanks for your advice,
Creature