void Heap_Stats(void);
// === GLOBALS ===
-tSpinlock glHeap;
+tMutex glHeap;
void *gHeapStart;
void *gHeapEnd;
#endif
// Lock Heap
- LOCK(&glHeap);
+ Mutex_Acquire(&glHeap);
// Traverse Heap
for( head = gHeapStart;
#else
if( head->Size & (MIN_SIZE-1) ) {
#endif
- RELEASE(&glHeap); // Release spinlock
+ Mutex_Release(&glHeap); // Release spinlock
#if WARNINGS
Log_Warning("Heap", "Size of heap address %p is invalid not aligned (0x%x)", head, head->Size);
Heap_Dump();
if(head->Magic == MAGIC_USED) continue;
// Error check
if(head->Magic != MAGIC_FREE) {
- RELEASE(&glHeap); // Release spinlock
+ Mutex_Release(&glHeap); // Release spinlock
#if WARNINGS
Log_Warning("Heap", "Magic of heap address %p is invalid (0x%x)", head, head->Magic);
Heap_Dump();
head->Magic = MAGIC_USED;
head->File = File;
head->Line = Line;
- RELEASE(&glHeap); // Release spinlock
+ Mutex_Release(&glHeap); // Release spinlock
#if DEBUG_TRACE
Log("[Heap ] Malloc'd %p (%i bytes), returning to %p", head->Data, head->Size, __builtin_return_address(0));
#endif
best = Heap_Extend( Bytes );
// Check for errors
if(!best) {
- RELEASE(&glHeap); // Release spinlock
+ Mutex_Release(&glHeap); // Release spinlock
return NULL;
}
// Check size
best->Magic = MAGIC_USED; // Mark block as used
best->File = File;
best->Line = Line;
- RELEASE(&glHeap); // Release spinlock
+ Mutex_Release(&glHeap); // Release spinlock
#if DEBUG_TRACE
Log("[Heap ] Malloc'd %p (%i bytes), returning to %p", best->Data, best->Size, __builtin_return_address(0));
#endif
best->File = File;
best->Line = Line;
- RELEASE(&glHeap); // Release spinlock
+ Mutex_Release(&glHeap); // Release spinlock
#if DEBUG_TRACE
Log_Debug("Heap", "newhead(%p)->Size = 0x%x", newhead, newhead->Size);
Log_Debug("Heap", "Malloc'd %p (0x%x bytes), returning to %s:%i",
}
// Lock
- LOCK( &glHeap );
+ Mutex_Acquire( &glHeap );
// Mark as free
head->Magic = MAGIC_FREE;
Heap_Merge( head );
// Release
- RELEASE( &glHeap );
+ Mutex_Release( &glHeap );
}
/**
}
/**
- * \fn void *Heap_AllocateZero(const char *File, int Line, size_t size)
+ * \fn void *Heap_AllocateZero(const char *File, int Line, size_t Bytes)
* \brief Allocate and Zero a buffer in memory
* \param File Allocating file
* \param Line Line of allocation
- * \param size Size of the allocation
+ * \param Bytes Size of the allocation
*/
-void *Heap_AllocateZero(const char *File, int Line, size_t size)
+void *Heap_AllocateZero(const char *File, int Line, size_t Bytes)
{
- void *ret = Heap_Allocate(File, Line, size);
+ void *ret = Heap_Allocate(File, Line, Bytes);
if(ret == NULL) return NULL;
- memset( ret, 0, size );
+ memset( ret, 0, Bytes );
return ret;
}