void Heap_Dump();
// === GLOBALS ===
- int giHeapSpinlock;
+ int glHeap;
void *gHeapStart;
void *gHeapEnd;
Bytes = (Bytes + sizeof(tHeapHead) + sizeof(tHeapFoot) + BLOCK_SIZE-1) & ~(BLOCK_SIZE-1);
// Lock Heap
- LOCK(&giHeapSpinlock);
+ LOCK(&glHeap);
// Traverse Heap
for( head = gHeapStart;
Warning("Size of heap address %p is invalid not aligned (0x%x)", head, head->Size);
Heap_Dump();
#endif
+ RELEASE(&glHeap);
return NULL;
}
Warning("Magic of heap address %p is invalid (0x%x)", head, head->Magic);
Heap_Dump();
#endif
- RELEASE(&giHeapSpinlock); // Release spinlock
+ RELEASE(&glHeap); // Release spinlock
return NULL;
}
// Perfect fit
if(head->Size == Bytes) {
head->Magic = MAGIC_USED;
- RELEASE(&giHeapSpinlock); // Release spinlock
+ RELEASE(&glHeap); // Release spinlock
#if DEBUG_TRACE
LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0));
#endif
best = Heap_Extend( Bytes );
// Check for errors
if(!best) {
- RELEASE(&giHeapSpinlock); // Release spinlock
+ RELEASE(&glHeap); // Release spinlock
return NULL;
}
// Check size
if(best->Size == Bytes) {
- RELEASE(&giHeapSpinlock); // Release spinlock
+ RELEASE(&glHeap); // Release spinlock
#if DEBUG_TRACE
LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0));
#endif
best->Size = Bytes; // Update size in old header
best->Magic = MAGIC_USED; // Mark block as used
- RELEASE(&giHeapSpinlock); // Release spinlock
+ RELEASE(&glHeap); // Release spinlock
#if DEBUG_TRACE
LOG("RETURN %p, to %p", best->Data, __builtin_return_address(0));
#endif
}
// Lock
- LOCK( &giHeapSpinlock );
+ LOCK( &glHeap );
// Mark as free
head->Magic = MAGIC_FREE;
Heap_Merge( head );
// Release
- RELEASE( &giHeapSpinlock );
+ RELEASE( &glHeap );
}
/**