Commit 10f8e503 by Marcus Winter

base_c: need to free mutex attributes in case of error

parent ca1e415c
......@@ -71,9 +71,13 @@ int embb_mutex_init(embb_mutex_t* mutex, int type) {
pthread_mutexattr_t attributes;
if (pthread_mutexattr_init(&attributes) != 0) return EMBB_ERROR;
if (pthread_mutexattr_settype(&attributes, PTHREAD_MUTEX_RECURSIVE) != 0) {
pthread_mutexattr_destroy(&attributes);
return EMBB_ERROR;
}
if (pthread_mutex_init(mutex, &attributes) != 0) {
pthread_mutexattr_destroy(&attributes);
return EMBB_ERROR;
}
if (pthread_mutex_init(mutex, &attributes) != 0) return EMBB_ERROR;
if (pthread_mutexattr_destroy(&attributes) != 0) return EMBB_ERROR;
}
return EMBB_SUCCESS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment