X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fheap.c;h=9d282b988040674bf494271ddaec537f243db48f;hb=144175640d070e26aa6a661a3a0014fa69e604dd;hp=3a0edb37993d0cf5775163eb92d16a1289400c9e;hpb=d1714d8a27a603ce8ac4ba91e8c0c3d060d767ee;p=tpg%2Facess2.git diff --git a/Kernel/heap.c b/Kernel/heap.c index 3a0edb37..9d282b98 100644 --- a/Kernel/heap.c +++ b/Kernel/heap.c @@ -151,7 +151,7 @@ void *malloc(size_t Bytes) // Alignment Check if( head->Size & (BLOCK_SIZE-1) ) { #if WARNINGS - Warning("Size of heap address %p is invalid not aligned (0x%x)", head, head->Size); + Log_Warning("Heap", "Size of heap address %p is invalid not aligned (0x%x)", head, head->Size); Heap_Dump(); #endif RELEASE(&glHeap); @@ -163,7 +163,7 @@ void *malloc(size_t Bytes) // Error check if(head->Magic != MAGIC_FREE) { #if WARNINGS - Warning("Magic of heap address %p is invalid (0x%x)", head, head->Magic); + Log_Warning("Heap", "Magic of heap address %p is invalid (0x%x)", head, head->Magic); Heap_Dump(); #endif RELEASE(&glHeap); // Release spinlock @@ -178,9 +178,9 @@ void *malloc(size_t Bytes) head->Magic = MAGIC_USED; RELEASE(&glHeap); // Release spinlock #if DEBUG_TRACE - LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0)); + Log("[Heap ] Malloc'd %p (%i bytes), returning to %p", head->Data, head->Size, __builtin_return_address(0)); #endif - return best->Data; + return head->Data; } // Break out of loop @@ -210,7 +210,7 @@ void *malloc(size_t Bytes) if(best->Size == Bytes) { RELEASE(&glHeap); // Release spinlock #if DEBUG_TRACE - LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0)); + Log("[Heap ] Malloc'd %p (%i bytes), returning to %p", best->Data, best->Size, __builtin_return_address(0)); #endif return best->Data; } @@ -231,7 +231,7 @@ void *malloc(size_t Bytes) RELEASE(&glHeap); // Release spinlock #if DEBUG_TRACE - LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0)); + Log("[Heap ] Malloc'd %p (%i bytes), returning to %p", best->Data, best->Size, __builtin_return_address(0)); #endif return best->Data; } @@ -246,8 +246,8 @@ void free(void *Ptr) tHeapFoot *foot; #if DEBUG_TRACE - LOG("Ptr = %p", Ptr); - LOG("Returns to %p", __builtin_return_address(0)); + Log_Log("Heap", "free: Ptr = %p", Ptr); + Log_Log("Heap", "free: Returns to %p", __builtin_return_address(0)); #endif // Alignment Check @@ -414,31 +414,31 @@ void Heap_Dump() while( (Uint)head < (Uint)gHeapEnd ) { foot = (void*)( (Uint)head + head->Size - sizeof(tHeapFoot) ); - Log("%p (0x%x): 0x%08lx 0x%lx", head, MM_GetPhysAddr((Uint)head), head->Size, head->Magic); - Log("%p 0x%lx", foot->Head, foot->Magic); - Log(""); + Log_Log("Heap", "%p (0x%x): 0x%08lx 0x%lx", head, MM_GetPhysAddr((Uint)head), head->Size, head->Magic); + Log_Log("Heap", "%p 0x%lx", foot->Head, foot->Magic); + Log_Log("Heap", ""); // Sanity Check Header if(head->Size == 0) { - Log("HALTED - Size is zero"); + Log_Warning("Heap", "HALTED - Size is zero"); break; } if(head->Size & (BLOCK_SIZE-1)) { - Log("HALTED - Size is malaligned"); + Log_Warning("Heap", "HALTED - Size is malaligned"); break; } if(head->Magic != MAGIC_FREE && head->Magic != MAGIC_USED) { - Log("HALTED - Head Magic is Bad"); + Log_Warning("Heap", "HALTED - Head Magic is Bad"); break; } // Check footer if(foot->Magic != MAGIC_FOOT) { - Log("HALTED - Foot Magic is Bad"); + Log_Warning("Heap", "HALTED - Foot Magic is Bad"); break; } if(head != foot->Head) { - Log("HALTED - Footer backlink is invalid"); + Log_Warning("Heap", "HALTED - Footer backlink is invalid"); break; }