summaryrefslogtreecommitdiff
path: root/mutex.c
diff options
context:
space:
mode:
Diffstat (limited to 'mutex.c')
-rw-r--r--mutex.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/mutex.c b/mutex.c
index 2259713..be68f5b 100644
--- a/mutex.c
+++ b/mutex.c
@@ -192,12 +192,20 @@ pthread_mutex_destroy(pthread_mutex_t *mutex)
{
result = (CloseHandle (mx->mutex) ? 0 : EINVAL);
}
- }
- if (result == 0)
+ if (result == 0)
+ {
+ mx->mutex = 0;
+ free(mx);
+ *mutex = NULL;
+ }
+ }
+ else
{
- mx->mutex = 0;
- free(mx);
+ /*
+ * This is all we need to do to destroy a statically
+ * initialised mutex that has not yet been used (initialised).
+ */
*mutex = NULL;
}