forked from enlightenment/efl
eina: replace memsets in thread debugging lock create/free with manual zeroing
Summary: memset overwrites the thread value, triggering errors when running tools like helgrind attempting an operation on an invalid thread will cause errors naturally, so zeroing the rest of the struct and ignoring the thread member is fine Reviewers: ManMower, devilhorns Reviewed By: ManMower Subscribers: cedric, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D6297
This commit is contained in:
parent
90cb995ac9
commit
44bafb0741
|
@ -162,6 +162,9 @@ eina_lock_new(Eina_Lock *mutex)
|
|||
Eina_Bool ret = _eina_lock_new(mutex, EINA_FALSE);
|
||||
#ifdef EINA_HAVE_DEBUG_THREADS
|
||||
mutex->recursive = EINA_FALSE;
|
||||
mutex->lock_thread_id = 0;
|
||||
mutex->lock_bt_num = 0;
|
||||
mutex->locked = 0;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
@ -172,6 +175,9 @@ eina_lock_recursive_new(Eina_Lock *mutex)
|
|||
Eina_Bool ret = _eina_lock_new(mutex, EINA_TRUE);
|
||||
#ifdef EINA_HAVE_DEBUG_THREADS
|
||||
mutex->recursive = EINA_TRUE;
|
||||
mutex->lock_thread_id = 0;
|
||||
mutex->lock_bt_num = 0;
|
||||
mutex->locked = 0;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,6 @@ _eina_lock_new(Eina_Lock *mutex, Eina_Bool recursive)
|
|||
}
|
||||
#ifdef EINA_HAVE_DEBUG_THREADS
|
||||
else if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK) != 0) goto fail_release;
|
||||
memset(mutex, 0, sizeof(Eina_Lock));
|
||||
#endif
|
||||
if (pthread_mutex_init(&(mutex->mutex), &attr) != 0) goto fail_release;
|
||||
ok = EINA_TRUE;
|
||||
|
@ -111,9 +110,6 @@ _eina_lock_free(Eina_Lock *mutex)
|
|||
|
||||
ok = pthread_mutex_destroy(&(mutex->mutex));
|
||||
if (ok != 0) EINA_LOCK_ABORT_DEBUG(ok, mutex_destroy, mutex);
|
||||
#ifdef EINA_HAVE_DEBUG_THREADS
|
||||
memset(mutex, 0, sizeof(Eina_Lock));
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
|
@ -124,7 +120,6 @@ _eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex)
|
|||
|
||||
#ifdef EINA_HAVE_DEBUG_THREADS
|
||||
assert(mutex != NULL);
|
||||
memset(cond, 0, sizeof (Eina_Condition));
|
||||
#endif
|
||||
|
||||
cond->lock = mutex;
|
||||
|
@ -167,9 +162,6 @@ EAPI void
|
|||
_eina_condition_free(Eina_Condition *cond)
|
||||
{
|
||||
pthread_cond_destroy(&(cond->condition));
|
||||
#ifdef EINA_HAVE_DEBUG_THREADS
|
||||
memset(cond, 0, sizeof (Eina_Condition));
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
|
|
Loading…
Reference in New Issue