In case of failure within eina_lock_new() (posix), a
pthread_mutexattr_t would have been left in an initialized state,
without any deinitialization being called.
Consequences would have been implementation defined.
eina_lock_new(Eina_Lock *mutex)
{
pthread_mutexattr_t attr;
+ Eina_Bool ok = EINA_FALSE;
#ifdef EINA_HAVE_DEBUG_THREADS
if (!_eina_threads_activated)
feature for sure with that change. */
#ifdef EINA_HAVE_DEBUG_THREADS
if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK) != 0)
- return EINA_FALSE;
+ goto fail_release;
memset(mutex, 0, sizeof(Eina_Lock));
#endif
if (pthread_mutex_init(&(mutex->mutex), &attr) != 0)
- return EINA_FALSE;
+ goto fail_release;
+ ok = EINA_TRUE;
+fail_release:
pthread_mutexattr_destroy(&attr);
-
- return EINA_TRUE;
+ return ok;
}
static inline void