Fixed some edge cases in heap where the spinlock was not releases
authorJohn Hodge <[email protected]>
Sat, 19 Jun 2010 02:57:04 +0000 (10:57 +0800)
committerJohn Hodge <[email protected]>
Sat, 19 Jun 2010 02:57:04 +0000 (10:57 +0800)
Kernel/heap.c

index a612d8a..8d1db7d 100644 (file)
@@ -177,6 +177,7 @@ void *malloc(size_t Bytes)
                        #if DEBUG_TRACE
                        Log("[Heap   ] Malloc'd %p (%i bytes), returning to %p", head->Data, head->Size,  __builtin_return_address(0));
                        #endif
+                       RELEASE(&glHeap);
                        return head->Data;
                }
                
@@ -205,10 +206,11 @@ void *malloc(size_t Bytes)
                }
                // Check size
                if(best->Size == Bytes) {
-                       RELEASE(&glHeap);       // Release spinlock
+                       best->Magic = MAGIC_USED;       // Mark block as used
                        #if DEBUG_TRACE
                        Log("[Heap   ] Malloc'd %p (%i bytes), returning to %p", best->Data, best->Size, __builtin_return_address(0));
                        #endif
+                       RELEASE(&glHeap);       // Release spinlock
                        return best->Data;
                }
        }

UCC git Repository :: git.ucc.asn.au