Fixed the mutex problem

master
Allen Webster 2020-01-19 12:16:54 -08:00
parent 7817f8412d
commit 33aa987589
2 changed files with 2 additions and 5 deletions

View File

@ -301,6 +301,7 @@ mac_to_object(Plat_Handle handle){
function void
mac_init_recursive_mutex(pthread_mutex_t *mutex){
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(mutex, &attr);
}

View File

@ -748,10 +748,8 @@ mac_memory_allocate_extended(void *base, u64 size, String_Const_u8 location){
pthread_mutex_lock(&memory_tracker_mutex);
{
zdll_assert_good(Memory_Annotation_Tracker_Node, memory_tracker.first);
zdll_push_back(memory_tracker.first, memory_tracker.last, node);
memory_tracker.count += 1;
zdll_assert_good(Memory_Annotation_Tracker_Node, memory_tracker.first);
}
pthread_mutex_unlock(&memory_tracker_mutex);
@ -769,10 +767,8 @@ mac_memory_free_extended(void *ptr){
pthread_mutex_lock(&memory_tracker_mutex);
{
zdll_assert_good(Memory_Annotation_Tracker_Node, memory_tracker.first);
zdll_remove(memory_tracker.first, memory_tracker.last, node);
memory_tracker.count -= 1;
zdll_assert_good(Memory_Annotation_Tracker_Node, memory_tracker.first);
}
pthread_mutex_unlock(&memory_tracker_mutex);